Skip to main content

What is Hosted Stdio-based MCP Server?

Run a hosted MCP server via stdio and expose it through the AI Gateway.
Recommended for local development in IDEs only.
Hosted stdio MCP servers are now available as first-class MCP servers with built-in per-user or global credential support via environment variables. A hosted stdio-based MCP server speaks the MCP over standard input and standard output (typical for CLI-style servers started with npx, uvx, or your own binary). TrueFoundry registers this pattern as a first-class MCP server: you provide the command, arguments, and environment variables for configuration and credentials, and the MCP Gateway runs and manages the process so clients use the same gateway URL as for remote MCP servers. This is useful when you already rely on a stdio MCP package or script and want centralized access, auth, guardrails, and observability without standing up a separate HTTP wrapper yourself.

How It Works?

You configure environment variables on the server (names and values). For per-user credentials, each value may include one templatized placeholder that the AI Gateway resolves from that caller’s Auth Overrides—the same substitution behavior as Individual Credentials on remote MCP servers (see MCP Gateway Auth & Security). Arbitrary or additional template syntax is not supported.

Create a Hosted Stdio-based MCP Server

1

Navigate to MCP Servers

Open the MCP Servers section in the TrueFoundry AI Gateway and choose Add Server.
2

Choose hosted stdio registration

Select Create a Hosted STDIO-based MCP Server. This path configures a command, arguments, and environment variables instead of a remote MCP URL.
3

Import from editor-style JSON (optional)

Paste MCP configuration JSON as a single-entry mcpServers map—the same shape as in Cursor or VS Code MCP config: one server id with command, args, and optional env. Only one server entry is allowed so the control plane can build one manifest.
4

Set command and arguments

Configure the process the AI Gateway should run:
5

Configure environment variables and access

Add environment variables required by the server (API keys, feature flags, and so on). Choose global credentials when everyone shares the same downstream access, or per-user when a value uses one templatized placeholder filled from each caller’s Auth Overrides. Add collaborators and roles as for any MCP server.
6

Create and test

Save the server, then use the Playground to list and invoke tools, and open How To Use for IDE and agent connection snippets.

Example manifests

Each example shows the editor-style JSON you can paste into the STDIO Configuration (JSON) box when adding the server in the UI, plus the equivalent full YAML manifest (type: mcp-server/stdio). Both examples run reference servers from the official modelcontextprotocol/servers repository and need no credentials. For servers that take API keys, add the variables under env (JSON) or auth_data.env (YAML). The JSON carries only command, args, and env—after pasting, mark each environment variable as global or per-user and add collaborators in the form.
Replace the collaborator subject with a real user in your account. Do not commit real API keys—use a secret store or placeholder for global env values. For per-user env values, use one templatized placeholder per value and configure each caller in Auth Overrides.
Runs the official filesystem server. The trailing argument is the directory the server is allowed to access—paths are inside the gateway sandbox, so tools operate on sandbox-local files. No credentials are needed, so auth_data is omitted.

Using Private Packages

Stdio MCP servers can run packages that are not published to the public npm registry or PyPI. No extra gateway configuration is needed: the environment variables you set in auth_data.env are available to the package manager (npx, uvx) when it installs the package inside the sandbox, so registry and repository credentials flow the same way as any other credential.
Never put tokens in args. Arguments are stored in plain text in the manifest and can appear in process listings. Keep every credential in auth_data.env.
Two patterns are supported: Registry credentials are usually global (one shared read token for installing the package), even when the server’s own downstream credentials are per-user.
Installs @your-org/your-mcp-server from GitHub Packages. The --@your-org:registry argument routes the scope to the private registry, and npm reads the token from the npm_config_//<registry-host>/:_authToken environment variable.
For Artifactory or Azure Artifacts, replace the registry URL in both the --@your-org:registry argument and the npm_config_//<registry-host>/:_authToken variable name with your registry’s host and path.

Troubleshooting private package installs

Install failures do not surface as errors: the server stays in the mcp_server_starting state indefinitely because the package manager never hands off to the MCP process. If your server is stuck starting, check these causes:
A git URL without #ref (npm) or @ref (uv) can make the install run git checkout null and hang. Always pin a tag, branch, or commit in the package URL.
npm normalizes package URLs and strips embedded credentials, so git+https://user:token@github.com/... in args fails to authenticate. Inject the token with git’s insteadOf URL rewriting from an environment variable, as shown in the private git repository examples.
If the first npx run is killed or fails partway, the partial download in ~/.npm/_npx inside the sandbox makes subsequent starts fail the same way. Change something in the manifest args (for example, pin a different ref or add a flag): this re-keys the sandbox and starts from a clean cache.
Environment variable values are part of the sandbox identity. Updating a token in auth_data.env automatically creates a fresh sandbox with the new value on the next start; the old sandbox ages out. If the server still fails after rotation, verify the new token has read access to the package.

Frequently Asked Questions

Clients connect over streamable HTTP POST requests, and any MCP method your stdio server implements is forwarded. Standalone server-initiated notifications outside a request’s response stream are not delivered. The gateway runs your server via the mcp-proxy library in a sandboxed environment in stateless mode, so the same per-request semantics as remote servers apply — see MCP Protocol Support for the full feature matrix.
Remote servers point at an HTTP (or streamable HTTP) MCP URL. Stdio servers describe a local process (command + args) the AI Gateway runs. Pick remote when you already have a URL; pick stdio when your integration is packaged as a stdio CLI.
Yes. After registration, you can include its tools in a Virtual MCP Server alongside tools from OpenAPI or remote servers.
For per-user credentials, one templatized placeholder per environment variable value is supported; the AI Gateway substitutes it using Auth Overrides, consistent with Individual Credentials elsewhere. Multiple placeholders or other template syntax in the same value are not supported.
Yes. Install from a private registry (npm or Python index) with the registry token in auth_data.env, or directly from a private git repository using a shell wrapper that injects the token through git configuration. See Using Private Packages for complete manifests and troubleshooting.
Yes. Traffic through the MCP Gateway is subject to the same controls and observability patterns as other registered MCP server types, consistent with OpenAPI-backed MCP servers and remote servers.

Best Practices

Pin versions

Prefer explicit package versions in args (for example pinned npx or uvx targets) so tool behavior does not change unexpectedly when upstream releases update.

Least-privilege environment variables

Pass only the environment variables the process needs, and use per-user auth when each caller should use their own downstream credentials.

Align with local dev

Keep command and args aligned with a working local MCP config so debugging stays straightforward.

Scope private-package tokens

For private registries and repositories, use a fine-grained token with read-only access scoped to the single package or repository the server installs—never a broad organization-wide token.