feat(mcp): bridge governed memory tools (memory.*) through squad_state MCP server - #1245
feat(mcp): bridge governed memory tools (memory.*) through squad_state MCP server#1245tamirdresher wants to merge 1 commit into
Conversation
The governed memory tools (memory.classify, memory.write, memory.search, memory.promote, memory.delete, memory.audit) are registered in the SDK ToolRegistry but were not exposed via the squad_state MCP server. As a result, autonomous agents running in Copilot CLI could not discover or invoke them — the entire classification/audit/search surface was reachable only via the CLI or direct SDK consumers. This change adds 6 entries to MCP_TOOL_ALIASES in state-mcp.ts so the existing MCP server advertises the memory tools alongside the existing squad_state_* family. The alias keys use underscores (memory_classify, etc.) per MCP cross-client safety; the values keep the dotted SDK tool names so the lookup against the ToolRegistry is unchanged. No SDK changes. No init/upgrade config changes. No new MCP server needed. No behavior change to existing squad_state_* or squad_decide flows. Closes #1244 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 10 check(s) still running |
Files Changed (3 files, +66 −0)
| File | +/− |
|---|---|
.changeset/memory-mcp-bridge.md |
+5 −0 |
packages/squad-cli/src/cli/commands/state-mcp.ts |
+9 −0 |
test/cli/state-mcp.test.ts |
+52 −0 |
Total: +66 −0
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
🟡 Impact Analysis — PR #1245Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (1 file)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
There was a problem hiding this comment.
Pull request overview
This PR extends the squad_state MCP server bridge in squad-cli to advertise the governed memory tools (memory.*) via MCP-safe underscore aliases, making them discoverable/invocable by autonomous agents running under Copilot CLI.
Changes:
- Added 6
memory_*aliases inMCP_TOOL_ALIASES, routing to the SDK ToolRegistry’smemory.classify/write/search/promote/delete/audittools. - Expanded
state-mcpbridge tests to validate the full tool list (13 total) and exercise MCP routing formemory_classify. - Added a patch changeset for
@bradygaster/squad-cli.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/squad-cli/src/cli/commands/state-mcp.ts |
Adds MCP alias entries to expose governed memory tools through the existing squad_state MCP server. |
test/cli/state-mcp.test.ts |
Adds tests asserting the expanded tool list and validates MCP routing for memory_classify. |
.changeset/memory-mcp-bridge.md |
Patch changeset documenting the new MCP exposure of governed memory tools in the CLI. |
| it('routes memory_classify via MCP to the SDK ToolRegistry memory.classify handler', { timeout: 30000 }, async () => { | ||
| const messages: JsonRpcMessage[] = []; | ||
| const session = createStateMcpSession(TMP, message => messages.push(message as JsonRpcMessage)); | ||
|
|
||
| await session.handleRequest({ | ||
| jsonrpc: '2.0', | ||
| id: 'classify', | ||
| method: 'tools/call', | ||
| params: { | ||
| name: 'memory_classify', | ||
| arguments: { content: 'Always deploy on Tuesdays' }, | ||
| }, | ||
| }); | ||
|
|
||
| const result = resultAsRecord(messages[0]!); | ||
| expect(result['isError']).not.toBe(true); | ||
| const content = result['content'] as Array<{ type: string; text: string }>; | ||
| expect(content).toBeDefined(); | ||
| expect(content[0]?.type).toBe('text'); | ||
| // The classification result should be a non-empty text response | ||
| expect(content[0]?.text.length).toBeGreaterThan(0); | ||
| }); | ||
|
|
Empirical re-test — bridge works, but MCP loading is the real blockerAfter PR was filed, I built this branch locally and ran a series of A/B tests against the test repo to verify the fix actually changes agent behavior. Test setup
Test 1 — bridge works in isolation
So the bridge fix itself is correct and the tools are reachable. Test 2 — full directive flow exposes a second blockerI then ran the realistic flow (user gives a directive, expects the team to remember it) under three configurations:
The bridge alone is necessary but not sufficient. With a plain workspace Recommendation
Verified locally on Windows 10 / Node 24.16 / |
|
|
Closes #1244
Summary
Adds 6 entries to
MCP_TOOL_ALIASESinpackages/squad-cli/src/cli/commands/state-mcp.tsso the existingsquad_stateMCP server advertises the governed memory tools alongside thesquad_state_*family. Without this change, the memory.* tools are registered in the SDK ToolRegistry but invisible to agents running in Copilot CLI.What changes
MCP_TOOL_ALIASESgrows from 7 → 13 entriesmemory_classify,memory_write,memory_search,memory_promote,memory_delete,memory_audit→ routed to the existing SDK ToolRegistry toolsmemory.classify, etc.What does NOT change
squad_stateMCP server registration is unchanged)squad_state_*orsquad_decideflowstools: ["*"]automatically pick up the new toolsWhy this matters
The governed memory subsystem (classification, audit log, forbidden-scan, loadGuidance) was previously reachable only from the CLI (
squad memory ...) and direct SDK consumers. Autonomous agents in Copilot CLI couldn't invoke it, so the safety/governance benefits were dormant for the runtime path that Squad teams actually use. With this change, agents can:memory_classifybefore committingmemory_writememory_searchmemory_promote/memory_deletememory_auditTest plan
npm run buildpassesstate-mcptests pass (2 existing + 2 new)lists all 13 tools including the 6 governed memory bridgesroutes memory_classify via MCP to the SDK ToolRegistry memory.classify handler@bradygaster/squad-cli)Out of scope
squad_memoryMCP server (this PR uses the existingsquad_stateserver — simpler, no new install)