Repository navigation
feat(chart)!: scope the break-glass MCP server to Gameplane namespaces (spec 037) #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+392
−38
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cbc15d7
feat(chart): scope the break-glass MCP server to Gameplane namespaces…
claude f4b881e
chore(changelog): number the MCP namespace scope entry
claude 58260bf
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 4bd2bc2
chore(changelog): link the MCP namespace scope entry to its PR
claude 21ec159
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 4f03d85
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude a064187
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 778fd59
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude d015b01
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 31d1e94
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 8a70015
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 88ca0ea
Merge branch 'feat/037-mcp-token-api' into feat/037-mcp-scope-chart
claude 8236e83
chore(mcp-server): bump to per-user mode and namespace scope (Gamepla…
claude d75b30f
test(chart): refuse MCP RoleBindings outside the in-scope namespaces
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Breaking: MCP server no longer reads every namespace | ||
|
|
||
| The break-glass MCP server (`mcpServer.enabled`) no longer has a cluster-wide | ||
| ClusterRole for Pods, Events and pod logs. The chart removes the old | ||
| `<release>-mcp-server-read` ClusterRole and ClusterRoleBinding on upgrade. Break-glass | ||
| reads now cover only the release namespace and the managed game namespaces, through | ||
| namespaced Roles. A ClusterRole remains for GameTemplate, Module and ModuleSource only. | ||
| After upgrading, use a personal MCP token (`/users/me/mcp-tokens`) for per-user reads | ||
| across clusters. See [`docs/security.md`](docs/security.md#mcp-server-optional). | ||
| [PR #1046](https://github.com/GameplanePanel/Gameplane/pull/1046) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #!/usr/bin/env bash | ||
| # Render the MCP server RBAC and check that it stays namespaced, read-only and in scope. | ||
| set -euo pipefail | ||
| cd "$(dirname "$0")/../../.." | ||
| scratch="$(mktemp -d)" | ||
| trap 'rm -rf "$scratch"' EXIT | ||
| helm template gameplane charts/gameplane --namespace gameplane-system \ | ||
| --set mcpServer.enabled=true --set 'operator.gameNamespaces={tenant-b}' > "$scratch/enabled.yaml" | ||
| helm template gameplane charts/gameplane --namespace gameplane-system \ | ||
| --set mcpServer.enabled=false > "$scratch/disabled.yaml" | ||
| python3 - "$scratch" <<'PY' | ||
| import pathlib,sys,yaml | ||
| root=pathlib.Path(sys.argv[1]) | ||
| SA='gameplane-mcp-server' | ||
| RELEASE_NS='gameplane-system' | ||
| EXPECTED_NS=['gameplane-system','gameplane-games','tenant-b'] | ||
| READ_VERBS={'get','list','watch'} | ||
|
|
||
| def docs(path): | ||
| return [d for d in yaml.safe_load_all(path.read_text()) if d] | ||
|
|
||
| def is_sa_subject(subject): | ||
| return subject.get('kind')=='ServiceAccount' and subject.get('name')==SA | ||
|
|
||
| def sa_objects(all_docs): | ||
| return [d for d in all_docs if d.get('kind') in ('ClusterRoleBinding','RoleBinding') | ||
| and any(is_sa_subject(s) for s in d.get('subjects') or [])] | ||
|
|
||
| enabled=docs(root/'enabled.yaml') | ||
| # Map each SA binding to the role it references. | ||
| bound=[] | ||
| for b in sa_objects(enabled): | ||
| ref=b['roleRef'] | ||
| bound.append((b['kind'], b['metadata'].get('namespace'), ref['kind'], ref['name'])) | ||
|
|
||
| def rules_for(kind, name, namespace=None): | ||
| for d in enabled: | ||
| if d.get('kind')==kind and d['metadata']['name']==name: | ||
| if kind=='Role' and d['metadata'].get('namespace')!=namespace: | ||
| continue | ||
| return d.get('rules') or [] | ||
| raise AssertionError(f'missing {kind} {name} {namespace}') | ||
|
|
||
| # 1. No ClusterRole bound to the SA grants pods, events or pods/log. | ||
| for bkind, bns, rkind, rname in bound: | ||
| if rkind!='ClusterRole': | ||
| continue | ||
| for rule in rules_for('ClusterRole', rname): | ||
| resources=set(rule.get('resources') or []) | ||
| assert not resources & {'pods','events','pods/log'}, (rname, rule) | ||
|
|
||
| # 2. Catalog ClusterRole has exactly gametemplates, modules, modulesources. | ||
| catalog=[b for b in bound if b[0]=='ClusterRoleBinding' and b[2]=='ClusterRole'] | ||
| assert len(catalog)==1, catalog | ||
| catalog_rules=rules_for('ClusterRole', catalog[0][3]) | ||
| assert len(catalog_rules)==1, catalog_rules | ||
| assert set(catalog_rules[0]['resources'])=={'gametemplates','modules','modulesources'}, catalog_rules | ||
| assert catalog_rules[0]['apiGroups']==['gameplane.local'], catalog_rules | ||
|
|
||
| # 3. Namespaced Roles with the expected name exist and are bound to the SA, once per namespace. | ||
| role_ns=sorted(ns for bkind, ns, rkind, rname in bound | ||
| if bkind=='RoleBinding' and rkind=='Role' and rname=='gameplane-mcp-server-read') | ||
| assert role_ns==sorted(EXPECTED_NS), role_ns | ||
| # Every RoleBinding for the SA, whatever role it names, stays inside the scope. | ||
| stray=[(ns, rname) for bkind, ns, rkind, rname in bound if bkind=='RoleBinding' and ns not in EXPECTED_NS] | ||
| assert not stray, stray | ||
| for ns in EXPECTED_NS: | ||
| rules_for('Role','gameplane-mcp-server-read',ns) | ||
|
|
||
| # 4. No rule bound to the SA has a verb other than get/list/watch (pods/log allows get only). | ||
| for bkind, bns, rkind, rname in bound: | ||
| for rule in rules_for(rkind, rname, bns if rkind=='Role' else None): | ||
| verbs=set(rule.get('verbs') or []) | ||
| assert verbs<=READ_VERBS, (rname, rule) | ||
| if set(rule.get('resources') or [])=={'pods/log'}: | ||
| assert verbs=={'get'}, rule | ||
|
|
||
| # 5. Deployment env lists exactly the in-scope namespaces. | ||
| deployments=[d for d in enabled if d.get('kind')=='Deployment' and d['metadata']['name']=='gameplane-mcp-server'] | ||
| assert len(deployments)==1 | ||
| env={e['name']:e.get('value') for e in deployments[0]['spec']['template']['spec']['containers'][0].get('env') or []} | ||
| assert sorted(env.get('GAMEPLANE_MCP_NAMESPACES','').split(','))==sorted(EXPECTED_NS), env | ||
|
|
||
| # 6. Disabled: no object references the SA. | ||
| disabled=docs(root/'disabled.yaml') | ||
| leftovers=[(d['kind'], d['metadata']['name']) for d in disabled | ||
| if d.get('kind') in ('ServiceAccount','Deployment','Role','RoleBinding','ClusterRole','ClusterRoleBinding') | ||
| and ('mcp-server' in d['metadata']['name'] or d['metadata']['name']==SA)] | ||
| assert not leftovers, leftovers | ||
| assert not sa_objects(disabled), sa_objects(disabled) | ||
| print('mcp-server RBAC scope ok') | ||
| PY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule mcp-server
updated
14 files
| +160 −59 | README.md | |
| +3 −3 | fixadvice.go | |
| +342 −0 | internal/kube/allowlist_test.go | |
| +245 −33 | internal/kube/client.go | |
| +632 −0 | internal/panel/client.go | |
| +600 −0 | internal/panel/client_test.go | |
| +181 −0 | internal/panel/fanout.go | |
| +187 −0 | internal/panel/fanout_test.go | |
| +64 −0 | internal/panel/source_test.go | |
| +45 −0 | internal/reader/reader.go | |
| +99 −34 | main.go | |
| +46 −0 | panel_invariants_test.go | |
| +136 −85 | specs.md | |
| +30 −12 | tools.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.