Skip to main content
Glama
README.md
# mcp-cage

A hand-rolled [Model Context Protocol](https://modelcontextprotocol.io) server. No SDK:
the JSON-RPC handshake, framing, and dispatch are implemented directly from the
protocol spec, with zero runtime dependencies. The eventual goal is a server that
exposes sandboxed shell/file tools behind a declarative policy file — scoping
paths, rate-limiting calls, and redacting secrets from tool results — with every
request, policy decision, and response logged to a replayable JSONL audit trail.

## Status

This project is built autonomously, one milestone at a time, and gated on a
passing test suite — no change ships unless `npm test` is green.

**Current milestone: protocol core.** The server implements the MCP stdio
handshake (`initialize`, `notifications/initialized`, `tools/list`,
`tools/call`) with one demo tool. Sandboxed shell/file tools, the policy
engine, secret redaction, and the audit trail are not implemented yet and will
land in later milestones.

## Install

Requires Node.js 18 or later. No external packages are installed.

```sh
npm install
```

## Usage

Run the server directly; it speaks newline-delimited JSON-RPC 2.0 over
stdin/stdout, per the MCP stdio transport:

```sh
npm start
```

Or point any MCP-compatible client at the binary:

```sh
node ./bin/mcp-cage.js
```

Example session (one JSON object per line on stdin, one back on stdout):

```jsonc
// -> initialize
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"example"}}}
// <- result with serverInfo and the protocol version the server supports
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"mcp-cage","version":"0.1.0"}}}

// -> tell the server the client is ready (no response expected)
{"jsonrpc":"2.0","method":"notifications/initialized"}

// -> list tools
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"echo","description":"Returns the given text back unchanged.","inputSchema":{"type":"object","properties":{"text":{"type":"string"}},"required":["text"],"additionalProperties":false}}]}}

// -> call a tool
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"echo","arguments":{"text":"hello"}}}
{"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"hello"}]}}
```

Run the test suite:

```sh
npm test
```

## Dependencies

None. Node's built-in `node:test`, `node:assert`, and `node:child_process`
modules cover everything this milestone needs — a line-delimited JSON codec
and a JSON-RPC dispatcher are both small enough to not justify pulling in a
package.

## What this demonstrates

- **Model Context Protocol** — a server that speaks MCP's JSON-RPC handshake
  and exposes a tool over it, built directly from the spec rather than an
  SDK. The line-framed JSON-RPC codec is in
  [`src/jsonrpc.js`](src/jsonrpc.js); the `initialize` /
  `notifications/initialized` / `tools/list` / `tools/call` method dispatch
  and the handshake state machine are in `createDispatcher` in
  [`src/protocol.js`](src/protocol.js); the stdio wiring that turns stdin
  lines into dispatcher calls and writes responses back to stdout is
  `startServer` in [`src/server.js`](src/server.js).
- **Safety and guardrails** — not yet implemented. This milestone only
  builds the protocol core; the policy engine, path scoping, rate limiting,
  secret redaction, and audit trail described above are planned for upcoming
  milestones and will be documented here once they land.

TDQS

A3.6/5.0

Scored across 1 tool

Disambiguation4/5

With only one tool, there is no possibility of confusing it with another tool. However, the lack of any other tools means there is no meaningful set to disambiguate.

Naming Consistency4/5

The single tool name 'echo' is clear and verb-like, with no inconsistent conventions to violate. There is no broader pattern to evaluate, so consistency is trivially satisfied but not demonstrated.

Tool Count2/5

A single tool is far too thin for a general-purpose MCP server; it feels like a placeholder rather than a usable tool surface. The count is well below the typical 3-15 range for a coherent server.

Completeness1/5

The surface consists solely of an echo utility, with no create/read/update/delete or lifecycle operations for any identifiable domain. It is severely incomplete for any practical purpose.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues