mcp-go icon indicating copy to clipboard operation
mcp-go copied to clipboard

How to get the server process environment variables which set by the mcp client(such as cursor)?

Open cantoo opened this issue 7 months ago • 1 comments

RT. sorry that i don't find any examples of read server process environment variables by using mcp-go

{ "mcpServers": { "mymcp":{ "url": "http://localhost:8080/sse", "env": { "MY_ENV": "value" } } } }

how to read the MY_ENV value

cantoo avatar Apr 23 '25 05:04 cantoo

you can directly get 'MY_ENV' by os.Getenv('MY_ENV') in your code logic

qiuxuezhe1 avatar Apr 25 '25 08:04 qiuxuezhe1

you can directly get 'MY_ENV' by os.Getenv('MY_ENV') in your code logic

That doesn't make sense for SSE. The server doesn't have access to an environment variable on the client. How are we supposed to set API Keys?

twchad avatar May 10 '25 01:05 twchad

You'd usually set headers in the MCP config, though I'm not sure if Cursor supports this yet (as of a couple weeks ago, they did not).

rwjblue-glean avatar May 10 '25 02:05 rwjblue-glean

Goose doesn't support it either. How are people passing API_Keys from Cursor and Goose?

twchad avatar May 10 '25 06:05 twchad