singularity-forge/packages/mcp-server/README.md

263 lines
7.8 KiB
Markdown
Raw Normal View History

feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
# @gsd-build/mcp-server
MCP server exposing GSD orchestration tools for Claude Code, Cursor, and other MCP-compatible clients.
Start GSD auto-mode sessions, poll progress, resolve blockers, and retrieve results — all through the [Model Context Protocol](https://modelcontextprotocol.io/).
This package now exposes two tool surfaces:
- session/read tools for starting and inspecting GSD sessions
- MCP-native interactive tools for structured user input
- headless-safe workflow tools for planning, completion, validation, reassessment, metadata persistence, and journal reads
## Installation
```bash
feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
npm install @gsd-build/mcp-server
```
Or with the monorepo workspace:
```bash
# Already available as a workspace package
npx gsd-mcp-server
```
## Configuration
### Claude Code
Add to your project's `.mcp.json`:
```json
{
"mcpServers": {
"gsd": {
"command": "npx",
"args": ["gsd-mcp-server"],
"env": {
"GSD_CLI_PATH": "/path/to/gsd"
}
}
}
}
```
Or if installed globally:
```json
{
"mcpServers": {
"gsd": {
"command": "gsd-mcp-server"
}
}
}
```
### Cursor
Add to `.cursor/mcp.json`:
```json
{
"mcpServers": {
"gsd": {
"command": "npx",
"args": ["gsd-mcp-server"],
"env": {
"GSD_CLI_PATH": "/path/to/gsd"
}
}
}
}
```
## Tools
### Workflow tools
The workflow MCP surface includes:
- `gsd_decision_save`
- `gsd_save_decision`
- `gsd_requirement_update`
- `gsd_update_requirement`
- `gsd_requirement_save`
- `gsd_save_requirement`
- `gsd_milestone_generate_id`
- `gsd_generate_milestone_id`
- `gsd_plan_milestone`
- `gsd_plan_slice`
- `gsd_plan_task`
- `gsd_task_plan`
- `gsd_replan_slice`
- `gsd_slice_replan`
- `gsd_task_complete`
- `gsd_complete_task`
- `gsd_slice_complete`
- `gsd_complete_slice`
- `gsd_skip_slice`
- `gsd_validate_milestone`
- `gsd_milestone_validate`
- `gsd_complete_milestone`
- `gsd_milestone_complete`
- `gsd_reassess_roadmap`
- `gsd_roadmap_reassess`
- `gsd_save_gate_result`
- `gsd_summary_save`
- `gsd_milestone_status`
- `gsd_journal_query`
These tools use the same GSD workflow handlers as the native in-process tool path wherever a shared handler exists.
### Interactive tools
The packaged server now exposes `ask_user_questions` through MCP form elicitation. This keeps the existing GSD answer payload shape while allowing Claude Code CLI and other elicitation-capable clients to surface structured user choices.
`secure_env_collect` is still not exposed by this package. That path needs MCP URL elicitation or an equivalent secure bridge because secrets should not flow through form elicitation.
Current support boundary:
- when running inside the GSD monorepo checkout, the MCP server auto-discovers the shared workflow executor module
- outside the monorepo, set `GSD_WORKFLOW_EXECUTORS_MODULE` to an importable `workflow-tool-executors` module path if you want the mutation tools enabled
- `ask_user_questions` requires an MCP client that supports form elicitation
- session/read tools do not depend on this bridge
If the executor bridge cannot be loaded, workflow mutation calls will fail with a precise configuration error instead of silently degrading.
### `gsd_execute`
Start a GSD auto-mode session for a project directory.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `projectDir` | `string` | ✅ | Absolute path to the project directory |
| `command` | `string` | | Command to send (default: `"/gsd auto"`) |
| `model` | `string` | | Model ID override |
| `bare` | `boolean` | | Run in bare mode (skip user config) |
**Returns:** `{ sessionId, status: "started" }`
### `gsd_status`
Poll the current status of a running GSD session.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `sessionId` | `string` | ✅ | Session ID from `gsd_execute` |
**Returns:**
```json
{
"status": "running",
"progress": { "eventCount": 42, "toolCalls": 15 },
"recentEvents": [ ... ],
"pendingBlocker": null,
"cost": { "totalCost": 0.12, "tokens": { "input": 5000, "output": 2000, "cacheRead": 1000, "cacheWrite": 500 } },
"durationMs": 45000
}
```
### `gsd_result`
Get the accumulated result of a session. Works for both running (partial) and completed sessions.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `sessionId` | `string` | ✅ | Session ID from `gsd_execute` |
**Returns:**
```json
{
"sessionId": "abc-123",
"projectDir": "/path/to/project",
"status": "completed",
"durationMs": 120000,
"cost": { ... },
"recentEvents": [ ... ],
"pendingBlocker": null,
"error": null
}
```
### `gsd_cancel`
Cancel a running session. Aborts the current operation and stops the agent process.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `sessionId` | `string` | ✅ | Session ID from `gsd_execute` |
**Returns:** `{ cancelled: true }`
### `gsd_query`
Query GSD project state from the filesystem without an active session. Returns STATE.md, PROJECT.md, requirements, and milestone listing.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `projectDir` | `string` | ✅ | Absolute path to the project directory |
| `query` | `string` | ✅ | What to query (e.g. `"status"`, `"milestones"`) |
**Returns:**
```json
{
"projectDir": "/path/to/project",
"state": "...",
"project": "...",
"requirements": "...",
"milestones": [
{ "id": "M001", "hasRoadmap": true, "hasSummary": false }
]
}
```
### `gsd_resolve_blocker`
Resolve a pending blocker in a session by sending a response to the blocked UI request.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `sessionId` | `string` | ✅ | Session ID from `gsd_execute` |
| `response` | `string` | ✅ | Response to send for the pending blocker |
**Returns:** `{ resolved: true }`
## Environment Variables
| Variable | Description |
|----------|-------------|
| `GSD_CLI_PATH` | Absolute path to the GSD CLI binary. If not set, the server resolves `gsd` via `which`. |
| `GSD_WORKFLOW_EXECUTORS_MODULE` | Optional absolute path or `file:` URL for the shared GSD workflow executor module used by workflow mutation tools. |
The server also hydrates supported tool credentials from `~/.gsd/agent/auth.json` on startup. Keys saved through `/gsd config` become available to the MCP server process automatically, and any explicitly-set environment variable still wins.
## Architecture
```
┌─────────────────┐ stdio ┌──────────────────┐
feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
│ MCP Client │ ◄────────────► │ @gsd-build/mcp-server │
│ (Claude Code, │ JSON-RPC │ │
│ Cursor, etc.) │ │ SessionManager │
└─────────────────┘ │ │ │
│ ▼ │
feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
@gsd-build/rpc-client │
│ │ │
│ ▼ │
│ GSD CLI (child │
│ process via RPC)│
└──────────────────┘
```
feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
- **@gsd-build/mcp-server** — MCP protocol adapter. Translates MCP tool calls into SessionManager operations.
- **SessionManager** — Manages RpcClient lifecycle. One session per project directory. Tracks events in a ring buffer (last 50), detects blockers, accumulates cost.
feat: Headless Integration Hardening & Release (M002) (#2811) * feat: Migrated headless orchestrator to use execution_complete events,… - "src/headless.ts" - "src/headless-ui.ts" - "src/tests/headless-v2-migration.test.ts" GSD-Task: S06/T02 * test: Wired pi-coding-agent to re-export JSONL utils from @gsd/rpc-clie… - "packages/pi-coding-agent/src/modes/rpc/jsonl.ts" - "packages/pi-coding-agent/package.json" - "packages/rpc-client/src/index.ts" - "packages/rpc-client/src/jsonl.ts" - "packages/rpc-client/src/rpc-client.ts" - "packages/rpc-client/src/rpc-types.ts" - "packages/rpc-client/src/rpc-client.test.ts" - "packages/rpc-client/package.json" GSD-Task: S06/T03 * feat: Wire --resume flag to resolve session IDs via prefix matching and… - "src/headless.ts" - "dist/headless.js" GSD-Task: S01/T01 * test: Added 5 e2e integration tests proving headless JSON batch, SIGINT… - "src/tests/integration/e2e-headless.test.ts" GSD-Task: S01/T02 * test: Updated @gsd/rpc-client and @gsd/mcp-server to 2.52.0 with publis… - "packages/rpc-client/package.json" - "packages/mcp-server/package.json" - "packages/rpc-client/.npmignore" - "packages/mcp-server/.npmignore" GSD-Task: S02/T01 * chore: auto-commit after complete-milestone GSD-Unit: M002-gzq23a * fix: revert jsonl.ts to inline implementation — @gsd-build/rpc-client not available at source-level test time in CI The re-export from @gsd-build/rpc-client fails in CI because tests run against TypeScript source (--experimental-strip-types) before any build step. The npm dependency resolves to node_modules/ which requires dist/ to exist. Reverting to the original inline implementation eliminates the cross-package dependency for source-level imports.
2026-03-26 23:33:22 -06:00
- **@gsd-build/rpc-client** — Low-level RPC client that spawns and communicates with the GSD CLI process via JSON-RPC over stdio.
## License
MIT