Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CLAUDE.md

Guidance for Claude Code / AI agents working in this repo. **This file is loaded into every session — keep it lean.** It is orientation + behavior only; detailed reference lives in `docs/`.
Expand Down Expand Up @@ -146,6 +146,7 @@
- **Windows installer**: [docs/github-actions-windows-wix-research.md](docs/github-actions-windows-wix-research.md). **Prerelease** (`next` branch + `v*-rc.*` tags, opt-in, off stable channels): [docs/prerelease-builds.md](docs/prerelease-builds.md).

## Recent Changes
- 125-skills-over-mcp (PR-5): Go 1.26, backend + docs — native skills extension on `/mcp/s/<server>` only (`internal/server/skills_native.go`): with `enable_skills` on and the server not excluded the instance is built with `WithExtensions`+`WithResourceCapabilities`; an interceptor (inside `singleServerSessionGuard`, in front of the transport) answers `skills/list`, `skills/get`, `resources/read` from `ListAvailableSkills`/`AvailableSkillFile`, byte for byte (a mutating output policy withholds instead of rewriting), one `skill_access` row each (tool = method). Transport checks are reused, not copied: the request is first sent through the transport with its method replaced by `ping`, and a refusal is replayed unchanged. Endpoint lifecycle (`mcp_single_server.go`): instance, transport and generation acquired together under `singleServersMu` (`acquireSingleServerEndpoint`), retirement detaches all three and advances the generation baked into session ids (`newSingleServerSessionIDs(server, gen)`), retired GET streams end, the upstream name rides on the request (`withSingleServerEndpoint`, `singleServerNameFor(ctx, srv)`); retired from `RefreshSkillsAvailability` and lazily on acquisition. Docs: `docs/features/skills.md` "Native skills on single-server endpoints". **No new dependencies.**
- 126-day-two-activation (PR-A): Go 1.26, backend + docs — telemetry schema 17, instrumentation only (no onboarding, UI or API change). Install anchor: `storage.EnsureInstallAnchor` (own bucket `install_anchor`, written once in `runtime.New` after the Spec 080 shutdown marker and Spec 123 OAuth boot sweep, before any other startup write, only when `config.db` held no record other than `meta/schema_version` at open, `BoltDB.WasEmptyAtOpen`; never from onboarding writes; recorded with telemetry off; read once per process for both `day_two` and `window_age`). `upstream_outcomes {succeeded, unusable, succeeded_non_starter, coverage, window_age}` (`internal/telemetry/upstream_outcomes.go`): one outcome per LOGICAL call that dispatched (dispatch counts requests), begun right after `noteUpstreamDispatched` and deferred (`upstreamOutcome` in `internal/server/mcp_upstream_telemetry.go`) on the wrapper, direct routing and `code_execution` sub-calls, guarded by an AST test; part of the drained window (retries byte-identical); `coverage` from the persisted `outcome_window_undelivered` marker (`outcome_window.go`: set by the first outcome after start or a Drain, cleared after a 2xx only if nothing was counted since that drain, both under the outcome window's own mutex, never `deliveryMu`), `window_age` = install age when the window opened (start or Drain), `install_origin: fresh` personal only. `day_two {install_origin, install_age, success_scope_ever}` personal only (`day_two.go`: UTC calendar-date buckets; `success_scope.go` forward-only ordinal in the activation bucket). `runtime.StarterClassifier` (default false, `SetStarterClassifier` for PR-B) + `Runtime.RecordUpstreamOutcome`. `ScanForPII` closed-object rule `day_two_field_invalid`. Docs: `docs/features/telemetry.md` "Schema v17". **No new dependencies.**
- 125-skills-over-mcp (PR-3): Go 1.26, backend + CLI + docs — approved skills reach agents through three read-only built-ins, registered only while `enable_skills` is on (`MCPProxyServer.RefreshSkillsAvailability`: default registry, call-tool, code-execution and direct surfaces; never `/mcp/s/<server>`, never from `code_execution`): `retrieve_skills(query, limit)`, `load_skill(id, offset, limit, version)`, `read_skill_file(id, path, offset, limit, version)` (`internal/server/mcp_skills.go`). Everything comes from the approved copy through `Runtime.AvailableSkill` / `AvailableSkillFile` / `SearchAvailableSkills` (`internal/runtime/skills_agent.go`); one refusal `skill not found: <id>` for every unavailable reason; reach = `resolveActiveProfileWithSource` → `serverInScope`, tool policy not applied. Search: memory-only Bleve in `internal/skills/index`, one index per reach, every match re-checked against its record. Paging: parts of ≤60,000 bytes with `Version:` in the header. Output policy (`mcp_skills_output.go`): block/redact/strip on the whole file before paging, also on names, descriptions and file names; skills build a detector when a policy is switched on after start. Activity type `skill_access` (administrator-only, like `skill_quarantine_change`). Scoped REST: `GET /api/v1/servers/{id}/skills{,/content}` answer an agent token with available skills from the approved copy through the same policy. Records of skills a listing did not name are bounded (200 per server). Docs: `docs/features/skills.md` "Skills for agents". **No new dependencies.**
- 125-skills-over-mcp (PR-2): Go 1.26, backend + CLI + docs — the skills approval gate, still administrator-only and offered to no agent. `decideSkill` (`internal/runtime/skills_quarantine.go`) is the whole status rule: `manual` holds new and changed skills, `scan` approves a new skill only on a clean and complete scan and always holds a changed one, `auto` / `quarantine_enabled:false` approve; a hash equal to the approved one restores approved; `Blocked` survives everything. Scan (`skills_scan.go`): every text file in ≤48 KiB chunks through `ScanToolMetadataVerdict`, after the reads and outside the upstream timeout, 45 s per refresh with follow-up refreshes, 1 MiB and 2 min per skill (`size_cap` / `time_limit` are kept, `coverage` is retried), result bound to the content hash. Review-bound decisions (`skills_approval.go`): `ApproveSkillsReviewedAt` (expected hash per skill + incarnation, whole request refused with nothing written) and `SetSkillsBlockedAt`, records-only writes (`storage.UpdateSkillApprovals`). REST `POST /api/v1/servers/{id}/skills/approve|block|unblock` (409 `review_out_of_date` / `server_replaced`, 422 `skill_unusable`), CLI `mcpproxy skills approve|block|unblock`, `skills show --diff`. Activity type `skill_quarantine_change` is administrator-only on every activity read door and on SSE (`storage.IsAdminOnlyActivityType`). Docs: `docs/features/skills.md` "Reviewing skills". **No new dependencies.**
Expand Down
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ graph LR
| Spec 108 profiles v3: scoped profiles, client binding, scope-aware observability | In progress | P1 | 194/195 (99%) | [108-profiles-v3](./specs/108-profiles-v3/) | |
| Spec 109 navigation, scope filters and cross-surface UX consistency | In progress | P1 | 257/258 (100%) | [109-ux-navigation-consistency](./specs/109-ux-navigation-consistency/) | |
| Spec 124 work sessions and the failure timeline | In progress | P1 | 0/74 (0%) | [124-session-failure-timeline](./specs/124-session-failure-timeline/) | |
| Spec 125 Skills over MCP: catalog, approval gate, read-only agent tools | In progress | P1 | 44/51 (86%) | [125-skills-over-mcp](./specs/125-skills-over-mcp/) | |
| Spec 125 Skills over MCP: catalog, approval gate, read-only agent tools | In progress | P1 | 49/51 (96%) | [125-skills-over-mcp](./specs/125-skills-over-mcp/) | |
| Planning/docs truth automation | In progress | P2 | — | | |
| Discovery-quality eval harness (Spec 065 second half) | In progress | P3 | — | [065-evaluation-foundation](./specs/065-evaluation-foundation/) | |
| Spec 114 typed pending-call outcome + call correlation for long-running stdio tool calls | In review | P2 | — | | #1536 |
Expand Down Expand Up @@ -1439,7 +1439,7 @@ Legend: `shipped` ≥95% checked · `in-flight` 1–94% · `drafted` 0% · `—`
| [122-scanner-skillspector-checks](./specs/122-scanner-skillspector-checks/) | `shipped` | 31/31 (100%) |
| [123-oauth-token-encryption](./specs/123-oauth-token-encryption/) | `drafted` | 0/56 (0%) |
| [124-session-failure-timeline](./specs/124-session-failure-timeline/) | `drafted` | 0/74 (0%) |
| [125-skills-over-mcp](./specs/125-skills-over-mcp/) | `in-flight` | 44/51 (86%) |
| [125-skills-over-mcp](./specs/125-skills-over-mcp/) | `shipped` | 49/51 (96%) |
| [127-profile-argument-rules](./specs/127-profile-argument-rules/) | — | — |
| [128-server-list-outcomes](./specs/128-server-list-outcomes/) | — | — |
| [129-per-user-upstream-credentials](./specs/129-per-user-upstream-credentials/) | — | — |
33 changes: 31 additions & 2 deletions docs/features/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Call the tool again with that `offset` and `version`. The header is repeated on

### Where the tools are offered

On every MCP endpoint that offers `retrieve_tools`, and on the direct endpoint (`/mcp/all`) next to `describe_tool`. They are not offered on single-server endpoints (`/mcp/s/<server>`), and a `code_execution` script cannot call them. Turning `enable_skills` on or off adds or removes the tools at once and tells connected clients that the tool list changed. With the switch off, the tool list is the same as in a build without this feature.
On every MCP endpoint that offers `retrieve_tools`, and on the direct endpoint (`/mcp/all`) next to `describe_tool`. They are not offered on single-server endpoints (`/mcp/s/<server>`), which serve skills natively instead (see [Native skills on single-server endpoints](#native-skills)), and a `code_execution` script cannot call them. Turning `enable_skills` on or off adds or removes the tools at once and tells connected clients that the tool list changed. With the switch off, the tool list is the same as in a build without this feature.

### Activity

Expand All @@ -246,6 +246,33 @@ mcpproxy activity list --type skill_access

While the tools are offered, the instructions MCPProxy sends to every client name them, and `mcpproxy agent-instructions` adds a skills line to its snippet; see [Agent Instructions](agent-instructions.md).

## Native skills on single-server endpoints {#native-skills}

A client that implements the skills extension itself (for example the MCP Inspector, `--method skills/list --verify`) can connect to the single-server endpoint of one upstream, `http://127.0.0.1:8080/mcp/s/<server>`, and use its own skills interface and consent prompts. With `enable_skills` on and the server not excluded (`expose_skills: false`), that endpoint:

- announces the extension (`capabilities.extensions["io.modelcontextprotocol/skills"]`) and the `resources` capability it requires;
- answers `skills/list` with exactly the skills of that server that are available to agents, under the addresses the upstream uses (`skill://…`), with the frontmatter, digest and size of the approved copy. Only text files are listed: binary files are not served in this version. The whole listing is one page;
- answers `skills/get` for one of those addresses, and `resources/read` for one of their files.

What a client reads is the approved copy, byte for byte. The client checks the digests itself, so MCPProxy adds no header and rewrites nothing: when the output sanitisation policy would block or change a file, the read is refused (`skill output blocked by the output sanitisation policy`), and a skill whose address, file addresses or frontmatter the policy would change is left out of the listing. Sensitive-data detection still runs on every file read and records its findings without changing the bytes.

A held, changed, blocked or unusable skill is not listed, and asking for it by address answers `skill not found: <uri>` (`skills/get`) or `resource not found: <uri>` (`resources/read`), error code `-32002`, the same answer as for an address that does not exist.

The aggregated endpoints (`/mcp`, `/mcp/all`, `/mcp/code`, `/mcp/call`, `/mcp/p/<profile>`) never announce the extension. They offer the [skill tools](#agent-tools) instead.

**Same door as the tools.** A caller whose credential or profile does not reach the server gets the endpoint's `404`, exactly as for its tools. Each of the three requests is answered only after the endpoint's transport has accepted it the way it accepts a `tools/call`: a request without a session id, with a session id another endpoint issued, or with a protocol version the endpoint does not serve gets the same refusal a `tools/call` gets. The single-server endpoint currently serves protocol revisions for which the transport ignores the `Mcp-Method` and `Mcp-Name` headers.

**Ordinary resources stay ordinary.** Only `resources/read` of a skill address (`skill://…`, or a file address a skill of that server lists) is answered by the skills surface. Any other `resources/read` on the same endpoint goes to the endpoint's transport unchanged, gets the answer it gets without native skills, and is not recorded as a `skill_access`.

**Following the switch.** Turning `enable_skills` on or off, or changing a server's `expose_skills`, retires that server's single-server endpoint: its open streams are closed and the session ids it issued are refused (`404`), so the client initializes again and sees the new capabilities. Nothing has to be restarted.

**Activity.** Every native listing, entry and file read is a `skill_access` row with the method in the tool column (`skills/list`, `skills/get`, `resources/read`), the action (`list`, `load`, `read`), the outcome (`not_found` included) and the caller's session.

```bash
npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8080/mcp/s/hf --transport http \
--method skills/list --verify --require-digests
```

## Command line

All commands need a running core (`mcpproxy serve`) and administrator credentials. They support `-o json` and `-o yaml`. `approve`, `block` and `unblock` are described under [Reviewing skills](#reviewing-skills).
Expand Down Expand Up @@ -328,7 +355,9 @@ Approve, block, unblock and refresh require administrator credentials (the API k

**An agent gets `skill not found` for a skill I can see.** The skill is not available to that agent. Check, in this order: `mcpproxy skills list --server <name>` shows it `approved`, not blocked and `listed`; the server is enabled, not quarantined and has no `expose_skills: false`; the agent's token or profile includes the server. `mcpproxy activity list --type skill_access` shows the call and its outcome.

**An agent does not see the skill tools.** `enable_skills` is off, or the client is connected to a single-server endpoint (`/mcp/s/<server>`), where they are not offered.
**An agent does not see the skill tools.** `enable_skills` is off, or the client is connected to a single-server endpoint (`/mcp/s/<server>`), where they are not offered: a client that speaks the skills extension gets the server's skills natively there.

**A native client says the server does not declare the skills extension.** It is connected to an aggregated endpoint, `enable_skills` is off, or the server has `expose_skills: false`. Connect it to `/mcp/s/<server>`. After changing either switch, the client must initialize again (its old session id answers `404`).

**A skill I approved shows `changed`.** The server changed its content. Compare with `mcpproxy skills show <server>:<skill> --diff` and approve again if the change is fine. Agents keep being refused until then.

Expand Down
2 changes: 1 addition & 1 deletion internal/contracts/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (i *IntentDeclaration) Validate() *IntentValidationError {
if i.DataSensitivity != "" && !isValidDataSensitivity(i.DataSensitivity) {
return NewIntentValidationError(
IntentErrorCodeInvalidSensitivity,
fmt.Sprintf("Invalid intent.data_sensitivity '%s': must be public, internal, private, or unknown", i.DataSensitivity),
"Invalid intent.data_sensitivity: must be public, internal, private, or unknown",
map[string]interface{}{
"provided": i.DataSensitivity,
"valid_values": ValidDataSensitivities,
Expand Down
9 changes: 9 additions & 0 deletions internal/contracts/intent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ func TestIntentDeclaration_Validate(t *testing.T) {
if tt.wantErr && err != nil && err.Code != tt.wantErrCode {
t.Errorf("Validate() error code = %v, wantErrCode %v", err.Code, tt.wantErrCode)
}
if err != nil && tt.wantErrCode == IntentErrorCodeInvalidSensitivity {
const wantMessage = "Invalid intent.data_sensitivity: must be public, internal, private, or unknown"
if err.Message != wantMessage {
t.Errorf("Validate() error message = %q, want %q", err.Message, wantMessage)
}
if got := err.Details["provided"]; got != tt.intent.DataSensitivity {
t.Errorf("Validate() provided sensitivity = %q, want %q", got, tt.intent.DataSensitivity)
}
}
})
}
}
Expand Down
8 changes: 6 additions & 2 deletions internal/runtime/skills_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ type AvailableSkill struct {
Name string
Description string
ApprovedHash string
Files []storage.SkillFile
TotalSize int64
// Frontmatter is the approved copy's frontmatter as stored (JSON), for the
// native listing on /mcp/s/<server> (Spec 125 FR-029).
Frontmatter json.RawMessage
Files []storage.SkillFile
TotalSize int64
}

// publishSkillsChanged announces a change of a server's skills and moves the
Expand Down Expand Up @@ -88,6 +91,7 @@ func availableSkillOf(serverName string, rec *storage.SkillApprovalRecord) *Avai
Name: name,
Description: desc,
ApprovedHash: rec.ApprovedHash,
Frontmatter: append(json.RawMessage(nil), rec.Approved.Frontmatter...),
Files: append([]storage.SkillFile(nil), rec.Approved.Files...),
}
for _, f := range a.Files {
Expand Down
11 changes: 10 additions & 1 deletion internal/server/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,18 @@ type MCPProxyServer struct {
// own names. They are projections of the published direct catalog and are
// re-registered under directRefreshMu, after the direct surface. The lock
// order is directRefreshMu, then singleServersMu.
//
// singleServersMu is also each endpoint's lifecycle lock (Spec 125 D14): a
// request takes the instance, its transport and the endpoint generation
// together under it, and a retirement detaches all three under it. It is
// never held across serving a request or shutting a transport down.
singleServerOpts []mcpserver.ServerOption
singleServersMu sync.Mutex
singleServers map[string]*singleServerSurface
// singleServerGens is each endpoint's generation. It only grows within a
// process; a retirement advances it, so the session ids it issued earlier
// are refused.
singleServerGens map[string]uint64

// directRefreshMu serializes whole rebuilds so SetTools and the matching
// publishDirectCatalog cannot interleave with another rebuild's pair.
Expand Down Expand Up @@ -1059,7 +1068,7 @@ func injectAuthMetadata(ctx context.Context, args map[string]interface{}) map[st
if authMeta == nil {
return args
}
enriched := make(map[string]interface{}, len(args)+len(authMeta))
enriched := make(map[string]interface{}, len(args))
for k, v := range args {
enriched[k] = v
}
Expand Down
2 changes: 1 addition & 1 deletion internal/server/mcp_agent_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (p *MCPProxyServer) instructionsForCaller(ctx context.Context, srv *mcpserv
// A single-server surface (/mcp/s/<server>) stands in for the upstream
// server itself, so it answers with that server's own instructions and
// nothing of mcpproxy's.
if name, ok := p.singleServerNameFor(srv); ok {
if name, ok := p.singleServerNameFor(ctx, srv); ok {
if !p.singleServerAdmits(ctx, name) {
return ""
}
Expand Down
5 changes: 5 additions & 0 deletions internal/server/mcp_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,11 @@ func (p *MCPProxyServer) RefreshSkillsAvailability() {
}
p.directRefreshMu.Unlock()
}

// Spec 125 D14: a single-server instance's capabilities are fixed when it
// is built, so an endpoint whose native skills surface no longer matches
// the switch is retired and rebuilt on its next request.
p.retireStaleNativeSurfaces()
}

// buildAggregatedServerPrompts combines built-in prompts with upstream
Expand Down
Loading
Loading