Skip to content

Commit da16c4a

Browse files
committed
update stderr option and readme
1 parent 26acd09 commit da16c4a

File tree

7 files changed

+68
-10
lines changed

7 files changed

+68
-10
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ mcp-server-metamcp --metamcp-api-key <your-api-key> --transport sse --port 12006
6161

6262
With the SSE transport option, the server will start an Express.js web server that listens for SSE connections on the `/sse` endpoint and accepts messages on the `/messages` endpoint.
6363

64+
### Using as a Streamable HTTP server
65+
66+
```bash
67+
mcp-server-metamcp --metamcp-api-key <your-api-key> --transport streamable-http --port 12006
68+
```
69+
70+
With the Streamable HTTP transport option, the server will start an Express.js web server that handles HTTP requests. You can optionally use `--stateless` mode for stateless operation.
71+
6472
### Using with Docker
6573

6674
When running the server inside a Docker container and connecting to services on the host machine, use the `--use-docker-host` option to automatically transform localhost URLs:
@@ -71,17 +79,40 @@ mcp-server-metamcp --metamcp-api-key <your-api-key> --transport sse --port 12006
7179

7280
This will transform any localhost or 127.0.0.1 URLs to `host.docker.internal`, allowing the container to properly connect to services running on the host.
7381

82+
### Configuring stderr handling
83+
84+
For STDIO transport, you can control how stderr is handled from child MCP processes:
85+
86+
```bash
87+
# Use inherit to see stderr output from child processes
88+
mcp-server-metamcp --metamcp-api-key <your-api-key> --stderr inherit
89+
90+
# Use pipe to capture stderr (default is ignore)
91+
mcp-server-metamcp --metamcp-api-key <your-api-key> --stderr pipe
92+
93+
# Or set via environment variable
94+
METAMCP_STDERR=inherit mcp-server-metamcp --metamcp-api-key <your-api-key>
95+
```
96+
97+
Available stderr options:
98+
- `ignore` (default): Ignore stderr output from child processes
99+
- `inherit`: Pass through stderr from child processes to the parent
100+
- `pipe`: Capture stderr in a pipe for processing
101+
- `overlapped`: Use overlapped I/O (Windows-specific)
102+
74103
### Command Line Options
75104

76105
```
77106
Options:
78107
--metamcp-api-key <key> API key for MetaMCP (can also be set via METAMCP_API_KEY env var)
79108
--metamcp-api-base-url <url> Base URL for MetaMCP API (can also be set via METAMCP_API_BASE_URL env var)
80109
--report Fetch all MCPs, initialize clients, and report tools to MetaMCP API
81-
--transport <type> Transport type to use (stdio or sse) (default: "stdio")
82-
--port <port> Port to use for SSE transport (default: "12006")
83-
--require-api-auth Require API key in SSE URL path
110+
--transport <type> Transport type to use (stdio, sse, or streamable-http) (default: "stdio")
111+
--port <port> Port to use for SSE or Streamable HTTP transport, defaults to 12006 (default: "12006")
112+
--require-api-auth Require API key in SSE or Streamable HTTP URL path
113+
--stateless Use stateless mode for Streamable HTTP transport
84114
--use-docker-host Transform localhost URLs to use host.docker.internal (can also be set via USE_DOCKER_HOST env var)
115+
--stderr <type> Stderr handling for STDIO transport (overlapped, pipe, ignore, inherit) (default: "ignore")
85116
-h, --help display help for command
86117
```
87118

@@ -90,6 +121,7 @@ Options:
90121
- `METAMCP_API_KEY`: API key for MetaMCP
91122
- `METAMCP_API_BASE_URL`: Base URL for MetaMCP API
92123
- `USE_DOCKER_HOST`: When set to "true", transforms localhost URLs to host.docker.internal for Docker compatibility
124+
- `METAMCP_STDERR`: Stderr handling for STDIO transport (overlapped, pipe, ignore, inherit). Defaults to "ignore"
93125

94126
## Development
95127

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamcp/mcp-server-metamcp",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "MCP Server MetaMCP manages all your other MCPs in one MCP.",
55
"scripts": {
66
"build": "tsc && shx chmod +x dist/*.js",

src/client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
77
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
88
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
9-
import { ServerParameters } from "./fetch-metamcp.js";
9+
import { ServerParameters, IOType } from "./fetch-metamcp.js";
1010

1111
const sleep = (time: number) =>
1212
new Promise<void>((resolve) => setTimeout(() => resolve(), time));
@@ -33,11 +33,17 @@ export const createMetaMcpClient = (
3333
// Create the appropriate transport based on server type
3434
// Default to "STDIO" if type is undefined
3535
if (!serverParams.type || serverParams.type === "STDIO") {
36+
// Get stderr value from serverParams, environment variable, or default to "ignore"
37+
const stderrValue: IOType =
38+
serverParams.stderr ||
39+
(process.env.METAMCP_STDERR as IOType) ||
40+
"ignore";
41+
3642
const stdioParams: StdioServerParameters = {
3743
command: serverParams.command || "",
3844
args: serverParams.args || undefined,
3945
env: serverParams.env || undefined,
40-
stderr: "ignore",
46+
stderr: stderrValue,
4147
};
4248
transport = new StdioClientTransport(stdioParams);
4349
} else if (serverParams.type === "SSE" && serverParams.url) {
@@ -85,7 +91,7 @@ export const createMetaMcpClient = (
8591
const client = new Client(
8692
{
8793
name: "MetaMCP",
88-
version: "0.6.0",
94+
version: "0.6.1",
8995
},
9096
{
9197
capabilities: {

src/fetch-metamcp.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {
55
getMetaMcpApiKey,
66
} from "./utils.js";
77

8+
// Define IOType for stderr handling
9+
export type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
10+
811
// Define a new interface for server parameters that can be STDIO, SSE or STREAMABLE_HTTP
912
export interface ServerParameters {
1013
uuid: string;
@@ -14,6 +17,7 @@ export interface ServerParameters {
1417
command?: string | null;
1518
args?: string[] | null;
1619
env?: Record<string, string> | null;
20+
stderr?: IOType; // Optional field for stderr handling, defaults to "ignore"
1721
url?: string | null;
1822
created_at: string;
1923
profile_uuid: string;

src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { reportAllTools } from "./report-tools.js";
77
import { cleanupAllSessions } from "./sessions.js";
88
import { startSSEServer } from "./sse.js";
99
import { startStreamableHTTPServer } from "./streamable-http.js";
10+
import { IOType } from "./fetch-metamcp.js";
1011

1112
const program = new Command();
1213

@@ -33,10 +34,22 @@ program
3334
"--use-docker-host",
3435
"Transform localhost URLs to use host.docker.internal (can also be set via USE_DOCKER_HOST env var)"
3536
)
37+
.option(
38+
"--stderr <type>",
39+
"Stderr handling for STDIO transport (overlapped, pipe, ignore, inherit)",
40+
"ignore"
41+
)
3642
.parse(process.argv);
3743

3844
const options = program.opts();
3945

46+
// Validate stderr option
47+
const validStderrTypes: IOType[] = ["overlapped", "pipe", "ignore", "inherit"];
48+
if (!validStderrTypes.includes(options.stderr as IOType)) {
49+
console.error(`Invalid stderr type: ${options.stderr}. Must be one of: ${validStderrTypes.join(", ")}`);
50+
process.exit(1);
51+
}
52+
4053
// Set environment variables from command line arguments
4154
if (options.metamcpApiKey) {
4255
process.env.METAMCP_API_KEY = options.metamcpApiKey;
@@ -47,6 +60,9 @@ if (options.metamcpApiBaseUrl) {
4760
if (options.useDockerHost) {
4861
process.env.USE_DOCKER_HOST = "true";
4962
}
63+
if (options.stderr) {
64+
process.env.METAMCP_STDERR = options.stderr;
65+
}
5066

5167
async function main() {
5268
// If --report flag is set, run the reporting function instead of starting the server

src/mcp-proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const createServer = async () => {
4040
const server = new Server(
4141
{
4242
name: "MetaMCP",
43-
version: "0.6.0",
43+
version: "0.6.1",
4444
},
4545
{
4646
capabilities: {

0 commit comments

Comments
 (0)