Skip to content

MCP Server Env Vars Not Passed #259

Open
@asalef10

Description

@asalef10

I'm trying to pass env vars (like API_KEY) from mcp.json to my SSE server, but process.env.API_KEY is undefined at runtime.

**Here’s a simplified version of my config:

{
"mcpServers": {
"MY-SSE-SERVER": {
"url": "http://localhost:3000/sse",
"env": {
"API_KEY": " my-api-key"
}
}
}
}**

And the server code:
app.get("/sse", (req, res) => {
console.log("process.env.API_KEY:", process.env.API_KEY);
});

Am I missing a step to get these env vars injected? Or does MCP not pass them into the runtime like I assumed?

Any insight appreciated! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions