Repository navigation
feat(profiles): set_profile MCP tool + session resolver + REST /api/v1/profiles (Profiles v2 T2, MCP-3241) - #761
Conversation
…les v2 T2) Add the stateful set_profile MCP tool and a shared profile resolver so an agent can switch its active profile inside a live session. - SessionStore gains a mutex-guarded per-session active-profile map, cleared on session close (covers both the unregister hook and inactivity cleanup). - resolveActiveProfile implements the precedence: token profile_pin (T3 hook) > URL /mcp/p/<slug> (per-request override) > set_profile session selection > none. mcp-go exposes a stable per-session id via ClientSessionFromContext (no synthetic fallback needed). - retrieve_tools now searches the per-profile Bleve index (MCP-3240) for the resolved profile (no re-index on switch); shared index + scope post-filter remain as the allow-all fallback / defense in depth. - call_tool_* and code_execution now consult the resolved profile so a base /mcp session that ran set_profile is bounded too. - set_profile registered on the default, call-tool and code-exec servers. Refs MCP-3241 Co-Authored-By: Paperclip <[email protected]>
…rofiles v2 T2) GET /api/v1/profiles lists configured profiles with effective servers and indexed tool count. GET/PUT /api/v1/profiles/active read/write a server-level default active profile for Web UI + tray (T4/T5). The default is UI-facing and does not override a live MCP session's set_profile selection. Refs MCP-3241 Co-Authored-By: Paperclip <[email protected]>
…rofiles (Profiles v2 T2) - profile_resolver_test.go: precedence (URL > session > none) + stale cleanup + SessionStore active-profile lifecycle. - profile_integration_test.go: e2e set_profile on base /mcp (switch/clear) + unknown-slug rejection. - profiles_test.go: REST list (tool counts) + active get/put round-trip + 404/400. - oas/swagger.yaml + docs.go regenerated (make swagger) with the new endpoints. Refs MCP-3241 Co-Authored-By: Paperclip <[email protected]>
… surface (Profiles v2 T2) Co-Authored-By: Paperclip <[email protected]>
Deploying mcpproxy-docs with
|
| Latest commit: |
a7645b9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e2f9b2c8.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://feat-mcp-3241-profiles-v2-t2.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 28115054436 --repo smart-mcp-proxy/mcpproxy-go
|
Code Review — CEO Agent (MCP-3340)Verdict: REQUEST_CHANGES — 3 correctness issues found. Finding 1 — Duplicate tool registration (major)File:
Finding 2 — Nil panic on sessionStore (major)File:
Finding 3 — TOCTOU on resolveActiveProfile (major)File:
Please address these before merge. |
Code Review: ACCEPTReviewer: CEO/Claude (run Verdict: ACCEPT — no blocking issues found Correctness ✅
Security ✅
Error Handling ✅
Test Coverage ✅
Minor (non-blocking)
Ready to merge. |
|
ACCEPT — Profiles v2 T2 (set_profile + session resolver + REST /api/v1/profiles) Code review by CEO (Claude) — head a7645b9 Verdict: ACCEPT ✅CI: all checks pass (build, CodeQL, cross-platform logging tests, frontend). No failing checks. What was reviewed:
Findings: None blocking.
Non-blocking observations:
Ready to merge. |
Profiles v2 — T2 (MCP-3241)
Builds on T1 (per-profile Bleve indexes, #756). Adds stateful, in-session profile switching plus a REST surface for UI.
What's in
set_profileMCP tool (internal/server/profile_tool.go):{profile}→ validates the slug, records it on the session, returns{active_profile, servers}; empty""clears back to all servers. Registered on the default, call-tool and code-exec servers.map[sessionID]profileNameonSessionStore, cleared on session close (covers both the unregister hook and inactivity cleanup). First subtask confirmed: mcp-go exposes a stable per-session id at tool-call time viaserver.ClientSessionFromContext(ctx).SessionID()— no synthetic fallback needed.internal/server/profile_resolver.go) with precedence (highest wins): agent-tokenprofile_pin(T3 hook, inert) > URL/mcp/p/<slug>(per-request override) >set_profilesession selection > none.retrieve_tools,call_tool_*,code_execution, and activity metadata all consult it;retrieve_toolssearches the per-profile index (no re-index on switch), with the shared index + scope post-filter as the allow-all fallback./api/v1/profiles(internal/httpapi/profiles.go):GETlists{name, servers, tool_count};GET/PUT /profiles/activeread/write a UI-facing server default.oas/swagger.yamlregenerated.docs/features/profiles.mddocumentsset_profile, the precedence table, and the REST surface.Tests
profile_resolver_test.go: precedence (URL > session > none) + stale-selection cleanup + SessionStore lifecycle.profile_integration_test.go: e2e on base/mcp—set_profile(research)scopesretrieve_tools, switch todeploy, clear restores all; unknown-slug rejection.profiles_test.go: REST list (tool counts) + active get/put round-trip + 404/400.Verification
go test -race ./internal/server/... ./internal/httpapi/...green (profile suite + full httpapi).golangci-lintv2 (.github/.golangci.yml): 0 issues../scripts/test-api-e2e.sh: 65/65 pass.make swaggercommitted.Refs MCP-3241 · Parent MCP-33 · Blocked-by (now merged) #756