Repository navigation
Replies: 4 comments
|
Hi, Following up on my own question — I ended up patching this locally with help of Claude Code, and it works well (even if I'm not a dev XD), so I'm sharing the approach in case it helps others (and to show what a native fix could look like). The good news is that the codebase already has everything needed: the calling token is available during request handling via the 1. New helper in def filter_servers_for_current_token(server_names: list[str]) -> list[str]:
token = current_token_info.get()
if token is None:
return list(server_names) # stdio / pre-auth: unchanged
allowed = list(getattr(token, "allowed_servers", None) or ["*"])
if "*" in allowed:
return list(server_names)
return [s for s in server_names if s in allowed]2. Per-token schema rewrite in the Right after
This also plays nicely with the existing 3. Token-aware default server ( This was the part that actually broke things in practice, as suspected in my second question: the fallback is global. A new helper replaces the 15 def _effective_default_server(client_manager) -> str | None:
allowed = filter_servers_for_current_token(client_manager.server_names)
default = client_manager.default_server
if default in allowed:
return default
return allowed[0] if allowed else defaultWith one token per tenant, a call that omits 4. Error messages (
Deploying without rebuilding the image The package is pip-installed in the image's venv, so the three modified files can simply be bind-mounted over the originals: volumes:
- ./patch/server.py:/opt/zabbix-mcp/venv/lib/python3.13/site-packages/zabbix_mcp/server.py:ro
- ./patch/client.py:/opt/zabbix-mcp/venv/lib/python3.13/site-packages/zabbix_mcp/client.py:ro
- ./patch/token_store.py:/opt/zabbix-mcp/venv/lib/python3.13/site-packages/zabbix_mcp/token_store.py:roThen Result observed: a restricted token's tool catalogue now only ever mentions its own instance, calls without Happy to open a PR with this if you're interested — and of course still curious whether per-token schema scoping is planned natively, since a local patch on |
|
Hi @sebdew, and first of all: sorry for the slow reply. We have been under a heavy load lately and holiday season on top of it, so this sat longer than it deserved. It was not for lack of interest. Please do open the PR - I would be glad to look at it. The direction is right, and you are not imagining the problem: our own internal review of the current release flagged exactly the same thing independently, in almost the same words. The Some of it is already on its way. The upcoming release makes a token scoped to exactly one server use that server as its default, so a call that omits Two things I noticed while reading the files you attached, so you can fold them in before you open it rather than after review: 1. The in-place mutation leaks across tokens. So after one request from token 2. It may be silently doing nothing on the current SDK. The patch reads If you are on the same SDK version, the improvement you observed is probably coming from your other two changes - the per-token default and the filtered error messages - rather than from the schema rewrite. Worth checking on your side before you conclude it works end to end; if your environment resolves it differently, I would genuinely like to know, because it tells us something about version drift we should handle. Neither of these is a reason to hesitate. They are the kind of thing a PR review is for, and finding them took reading your code, which is a compliment to how clearly you wrote it up. Thanks for the detailed report, the diagnosis and the offer - it is exactly the sort of contribution that makes this project better. |
|
Done in v1.41, without waiting for the PR - sorry it took from September.
|
|
Hi @hermanekt, Thank you very much for this, and for shipping it in v1.41 without waiting for my PR. I owe you an apology: I never followed up on your September reply, and the PR never came. Things got really hectic on my side from September onwards and this slipped through, which is a poor way to answer such a detailed and generous review. Sorry about that. Thanks as well for the two points you caught in my patch. The shared input_schema leak across tokens is exactly the kind of thing I would not have spotted on my own, and you are probably right that the schema rewrite was silently skipped on the current SDK, with the improvement I observed coming from the per-token default and the filtered error messages. Good to see both handled properly in the native fix. I'll upgrade to v1.41, drop my local bind-mounted patch, and test it on our multi-tenant setup as soon as possible. I'll report back here with the results. Thanks again for taking the MSP use case seriously, and for your work on this project. |
Uh oh!
There was an error while loading. Please reload this page.
Hi team,
A question about multi-server deployments where each
[zabbix.*]entry belongs to a different end customer rather than to a different environment (prod/staging).Setup
[zabbix.*]blocks, one per customer instance[tokens.*]per customer, each withallowed_serverslimited to that customer's instance and a restrictedscopeslistWhat I observe
In
tools/list, the description of theserverparameter on every tool enumerates all configured[zabbix.*]names and states which one is used by default. A token restricted throughallowed_serversstill receives the complete list in its tool catalogue. Removingextensionsfrom the token scopes (sohealth_checkis not exposed) makes no difference — which is consistent with the description being built from the config at registration time rather than per token.Questions
serverenumeration reflect the calling token'sallowed_servers? Or is the current behaviour intended, with instance names treated as non-sensitive metadata?serverfalls back to the first configured instance. Is that default global, or resolved per token? With one token per tenant, a call that omits the parameter would target another tenant's instance and get rejected byallowed_servers. Making the token's own allowed server the default would seem more natural in that setup.Why it matters here
In an MSP context the instance names carry customer identity, so customer A's assistant seeing customer B's instance name in its tool catalogue is difficult to justify contractually, even though no data is accessible across tenants.
Workaround I'm considering
One MCP instance per customer — a
config.tomlholding a single[zabbix.*]block, its own port and systemd unit (or container), each declared as a separate MCP server on the gateway. Not very happy to go that route, so I wanted to check first whether per-token schema scoping is planned, or whether I've simply missed a configuration option.Thanks for the work on this project.
All reactions