Skip to content

How to get environment variables on the server? #1277

@ilvalerione

Description

@ilvalerione

Question

I haven't been able to figure out how to get environment variables in tool functions on an MCP server, or if they're actually supported.

This should be a valid client configuration:

{
    "mcpServers": {
        "php-calculator": {
            "command": "python",
            "args": ["/absolute/path/to/your/mcp-server.py"], 
            "env": {"API_KEY": "xxxx"}
        }
    }
}

How can I get the API_KEY environment variable on the server?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions