A minimal MCP server, integrated with Keycard identity, authentication and authorization, using @keycardai/mcp, the official MCP v2 SDK (@modelcontextprotocol/server), and Express 5 over the Streamable HTTP transport.
This template is a plain Node project. There is no scaffolding step — copy the directory, install, and run.
cp -R mcp-server-typescript-express my-mcp-server
cd my-mcp-server
npm install
export KEYCARD_URL=https://your-url.keycard.cloud
npm run build
npm run startThe server listens on http://localhost:8000/mcp and registers itself against keycard at KEYCARD_URL.
npm run dev| Env var | Default | Purpose |
|---|---|---|
KEYCARD_URL |
(required) | URL the server registers against. |
KEYCARD_RESOURCE_ID |
mcp-server-typescript-express |
Keycard Resource id used by the middleware. |
PORT |
8000 |
Local HTTP port. |
Before the server can accept requests, the Keycard needs a Resource and a policy that lets your principal call the hello tool. See SPEC.md for the exact resources and policy shape the agent should provision.
Drop a new file in src/tools/ and register it from src/server.ts. Tools added here are automatically gated by your Keycard policy — see the keycard-upsert-policy skill for editing rules.