今日已更新 421 条资讯 | 累计 25080 条内容
关于我们

My MCP Server Holds Two API Keys. Every Tool Call Runs in the Same Process as Both.

Enjoy Kumawat 2026年07月28日 20:36 1 次阅读 来源:Dev.to

I read a post this week where someone connected three MCP servers to one agent and watched it casually request the same access it'd need to hit production. The comment thread was full of "yeah, that's the whole problem with MCP" takes, and I almost scrolled past it — I don't run three servers, I run one. Then I actually opened server.py to check, and realized my one server has the exact same shape of problem, just folded into a single file instead of spread across three. server.py is a FastMCP server with 8 tools split across two unrelated jobs: GitHub profile/repo reads, and DEV.to article reads and writes. Both credentials get loaded the same way, at import time, into the same process environment: def load_env ( path = " .env " ): try : with open ( path ) as f : for line in f : line = line . strip () if line and not line . startswith ( " # " ) and " = " in line : k , v = line . split ( " = " , 1 ) os . environ . setdefault ( k , v ) except FileNotFoundError : pass load_env () and two helper functions read them back out: def _gh ( path , method = " GET " , data = None ): req = urllib . request . Request ( f " https://api.github.com { path } " , method = method ) req . add_header ( " Authorization " , f " token { os . environ [ ' GITHUB_TOKEN ' ] } " ) ... def _dev ( path , method = " GET " , data = None ): req = urllib . request . Request ( f " https://dev.to/api { path } " , method = method ) req . add_header ( " api-key " , os . environ [ " DEV_TO_API " ]) ... Nothing here is a bug in the sense of "wrong output for some input." Every tool does exactly what it says: get_github_profile reads GitHub, create_article writes to DEV.to. The problem is one level up, in what the process boundary actually protects. I'd been thinking of GITHUB_TOKEN and DEV_TO_API as belonging to different tools , scoped by which function reads them. They don't. They belong to the process . Every one of those 8 tools runs with both credentials sitting in its environment, whether the tool ne

本文内容来源于互联网,版权归原作者所有
查看原文