Skip to content

Run your first server

Start with the tool server example. It answers questions about the type, growth habit, maturity time, and traits of two made-up pea varieties. It includes both ordinary tests and tests of AI tool choice and explanations.

You need Git, Node.js 22 or newer, and npm. Continuous integration (CI) exercises Node.js 22 and 24. This is a local development quickstart, not production deployment guidance.

The tool server example directory contains the maintained source and the public initializer package used below.

Run this command from a directory where you keep projects. Choose another name if my-mcp already exists.

Create the project
npm init @emseepea/tool-server -- my-mcp
cd my-mcp

The initializer creates a private standalone project. Its package.json uses published versions of @emseepea/server and @emseepea/testing. Em See Pea is beta; see maturity and support for the limits of that label.

Run these commands inside my-mcp:

Install and check
npm install --ignore-scripts
npm test
npm run lint

The tests build your server and call it through MCP. They do not require a language-model account. A passing run ends with no failed tests.

Start the server
npm start

The terminal prints its local MCP address, normally http://127.0.0.1:3000/mcp. Keep that terminal open while using the server. Stop it with Control-C. If port 3000 is in use, stop the other local example first.

Connect using an MCP client that supports MCP 2026-07-28 and Streamable HTTP. Add the printed address to that client’s server connections, then try asking:

What are the pea type, growth habit, days to maturity, and traits of Highland Snap?

Client setup varies. Older clients may not support this protocol version. The example’s tests use the matching official MCP client.

Open src/capabilities/tool.get-pea-variety.ts in your project:

  • varieties contains the sample data. Replace it with your own data.
  • inputSchema describes the names the tool accepts.
  • outputSchema describes the details it returns.
  • handler looks up the pea variety and returns structured data.

Em See Pea checks the input and output, returns the data as MCP structuredContent, and serializes the same data as JSON text for clients that do not consume structured content. Your handler supplies the behaviour. Update test/server.test.mjs for your data, then run npm test again.

src/server.ts calls discoverCapabilities(new URL("./capabilities/", import.meta.url)) once during startup. Explicit tools, resources, and prompts arrays still work when you need them.

Check the AI’s tool choice and explanation

Section titled “Check the AI’s tool choice and explanation”

The example’s eval/meaning.test.mjs checks that a model does not confuse pea type, growth habit, maturity time, and traits. Adapt its question and expected facts when you change the tool.

This check requires a signed-in Claude CLI and uses model allowance. See the AI testing guide for setup and what the results prove.

Check AI tool choice and understanding
npm run test:llm

The model sees the advertised tools and must select get-pea-variety with arguments that the real server accepts. The test then checks whether the model understands the returned pea variety details.

Browse the examples to connect a public API, add authentication, send progress updates, or add a web form.

To build and configure this project as a production container, read Build a production container.