Rename mcpserver package to extension, remove *mcp.Server field (#11)

## Summary

- Rename `interceptors/mcpserver/` → `interceptors/extension/`,
replacing the `Server` wrapper with a lightweight `Extension` that can
install itself on any `*mcp.Server`
- Remove the stored `*mcp.Server` field — `Extension` is now a pure
interceptor container with no server reference
- Add `Install(server)` method to register JSON-RPC methods and init
middleware on a given server
- Update `LocalChain(ctx)` → `LocalChain(ctx, server)` to accept the
server as a parameter
- Remove `MCPServer()`, `Run()`, and `NewStreamableHTTPHandler()`
wrapper methods — users interact with `mcp.Server` directly
- Update all examples, tests, and documentation to use the new API

## Why

`mcpserver.Server` pretended to *be* the server — it had `Run()`,
`NewStreamableHTTPHandler()`, etc. — but it could never cover the full
`*mcp.Server` API, so users constantly needed `MCPServer()` to unwrap
it.

`Extension` doesn't pretend to be the server. It's a pure interceptor
container that can install itself on any server (or multiple servers)
on the fly. No stored server reference, no wrapping, no delegation
surface to maintain.

### Before

```go
mcpServer := mcp.NewServer(...)
srv := mcpserver.NewServer(mcpServer)
srv.AddInterceptor(v)
chain, err := srv.LocalChain(ctx)
```

### After

```go
mcpServer := mcp.NewServer(...)
ext := extension.New()
ext.AddInterceptor(v)
ext.Install(mcpServer)
chain, err := ext.LocalChain(ctx, mcpServer)
```

Signed-off-by: Kurt Degiorgio <kdegiorgio@bloomberg.net>
This commit is contained in:
Kurt Degiorgio 2026-04-30 15:57:18 +01:00 • committed by GitHub
commit 074dc6cdbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,9 +5,10 @@
The Go SDK follows the SEP execution model where interceptors are
first-class MCP primitives:
1. **Interceptor Server** (`mcpserver.Server`) — wraps an `mcp.Server`,
registers interceptors, and exposes them via `interceptors/list` and
`interceptor/invoke` JSON-RPC methods.
1. **Interceptor Extension** (`extension.Extension`) — registers
interceptors and installs them on one or more `mcp.Server` instances,
exposing them via `interceptors/list` and `interceptor/invoke` JSON-RPC
methods.
2. **Chain** (`chain.Chain`) — the SDK-level orchestrator in the
`interceptors/chain` sub-package. It holds `ChainEntry` objects
(interceptor descriptor + MCP client session) and invokes interceptors
@ -31,8 +32,8 @@ Transport (SSE / stdio / HTTP)
## LocalChain: In-Memory Transport
`Server.LocalChain(ctx)` creates a chain connected to the server via
in-memory transport. Under the hood it:
`Extension.LocalChain(ctx, server)` creates a chain connected to the given
server via in-memory transport. Under the hood it:
1. Creates an `InMemoryTransport` pair via `mcp.NewInMemoryTransports()`
2. Connects the server side via `mcp.Server.Connect(ctx, serverTransport)`
@ -206,11 +207,11 @@ Response-phase validators see the post-mutation payload.
| `chain.go` | `Chain`, `ChainEntry`, `ExecutionParams`, `ExecutionResult`, `NewChain`, `AddMCPServer`, `Execute`; filtering, sorting, parallel validation, sequential mutation, trust-boundary ordering |
| `result.go` | Chain result types: ChainStatus, AbortType, AbortInfo, ValidationSummary |
### `interceptors/mcpserver/` — MCP server integration
### `interceptors/extension/` — MCP server integration
| File | Responsibility |
|------|---------------|
| `server.go` | `Server` wrapper, interceptor registry, `LocalChain`, capability declaration, `NewStreamableHTTPHandler` |
| `server.go` | `Extension`, interceptor management, `Install`, `LocalChain`, capability declaration |
| `rpc.go` | `handleList` and `handleInvoke` JSON-RPC method handlers |
| `events.go` | Event name constants for standard MCP methods |