mcp-typescript-template AGENTS.md

A set of repository guidelines for building an HTTP server in TypeScript that implements the Model Context Protocol, a standard way for AI tools to expose functions and data. It covers development, building, testing, formatting, and project structure.

In plain words
What is it for?
Use it when developing or maintaining this TypeScript MCP server. It guides local development, production builds, linting, formatting checks, and automated tests.
Why use it?
It gives contributors one consistent workflow for checking code before submission. It also shows where routing, tools, configuration, logging, and tests belong.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/nickytonline/mcp-typescript-template/agents-md
Clone the repo
git clone --depth 1 https://github.com/nickytonline/mcp-typescript-template

Made for: Codex, OpenCode.

Per session 1,741 This file is loaded in full into every session.
When invoked 1,741 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01741 $0.01741
Opus 5 $0.00870 $0.00870
Sonnet 5 $0.00348 $0.00348
Haiku 4.5 $0.00174 $0.00174

Measured 2d ago against content hash 5bb8a7e146cd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mcp-typescript-template AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Repository Guidelines

TypeScript template for building Model Context Protocol (MCP) servers over HTTP.

Key Commands

# Development (hot reload via native Node.js type stripping)
npm run dev

# Build (Vite → ES modules in dist/)
npm run build

# Production
npm start

# Lint & format
npm run lint
npm run lint:fix
npm run format
npm run format:check

# Tests
npm run test       # interactive Vitest
npm run test:ci    # outputs test-results.json

Before Submitting

Always run these and fix any failures before opening a PR:

npm run lint && npm run format:check && npm run build && npm run test:ci

Project Structure

src/
  index.ts       # HTTP routing via createMcpHandler + toNodeHandler (stateless, per-request); calls registerTools() in getServer()
  tools.ts       # registerTools() wiring + per-tool logic functions
  tools.test.ts  # colocated integration tests (in-memory client/server)
  config.ts      # Env var validation via Zod
  logger.ts      # Pino structured logging (OpenTelemetry compatible)
  lib/
    utils.ts       # MCP response helpers (createTextResult, createErrorResult)
    utils.test.ts  # colocated unit tests
dist/            # compiled output (ES modules)

Config files (vite.config.ts, tsconfig.json, eslint.config.js, Dockerfile) live at the repo root.

Architecture

  • HTTP transport via Express on PORT (default 3000) — not stdio
  • Tools registered via registerTools(server) in src/tools.ts, the single source of truth for tool wiring — called from getServer() in src/index.ts and reused by the tests
  • Tool responses use createTextResult / createErrorResult from src/lib/utils.ts: a text content block plus structuredContent (for clients that declare an outputSchema)
  • Genuine execution failures return isError: true (via createErrorResult), not thrown; valid outcomes (e.g. a user declining an elicitation) are normal results
  • Stateless per the MCP 2026-07-28 spec: no initialize/initialized handshake, no Mcp-Session-IdcreateMcpHandler's factory runs getServer() fresh for every HTTP request. It also serves older (2025-era) clients automatically via a stateless fallback, so no separate legacy transport is needed.
  • GET /health is a plain liveness endpoint (used by the Docker healthcheck) — GET /mcp itself is routed to the MCP handler and no longer doubles as one
  • If a tool needs state across calls, mint an explicit handle and have the model pass it back as an argument on the next call — there is no transport-level session to hang state off anymore
  • Graceful shutdown on SIGTERM/SIGINT (closes the handler, then exits)

Read the full file on GitHub · 141 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 141 lines · 1,741 tokens per session scan A 5bb8a7e146cd

Subscribe to this mod's changes

mcp-typescript-template AGENTS.md is an instructions file published in the GitHub repository nickytonline/mcp-typescript-template (54 stars, last pushed 23d ago), licensed MIT. It adds 1,741 tokens to every session, about $0.0087 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.