Choose an example
Each example includes application code, ordinary tests in test/, and
language-model tests in eval/. The first-server guide
shows how to copy the basic example into a project of your own.
The commands on this page run from the top level of an Em See Pea checkout.
First run npm ci --ignore-scripts, then npm run build there. They do not run
from the copied my-mcp project.
Run one example at a time. Each prints its local address; stop it with Control-C.
Answer questions about your data
Section titled “Answer questions about your data”Basic coffee tool. Read details from a small in-memory catalogue. Use it to learn the tool definition without another service to configure.
npm run start:basicConnect a public API
Section titled “Connect a public API”Public web service. Call an external JSON API and turn its response into an MCP result. Unlike the basic example, this demonstrates checks and mapping between your tool’s contract and a service’s different contract.
npm run start:backendRequire sign-in for a tool
Section titled “Require sign-in for a tool”Anyone can discover the server and list tools. Calling the restricted tool requires the example’s made-up access token. Replace that token checker before using it in a real application.
npm run start:protectedShare reference material and prompts
Section titled “Share reference material and prompts”Provide readable resources, resource addresses with parameters, reusable prompts, and suggestions for prompt fields.
npm run start:resources-promptsRead the resources and prompts example.
Report progress during a tool call
Section titled “Report progress during a tool call”Send updates over the call’s open HTTP connection, then return the final result. This is not a saved session or a reconnectable subscription.
npm run start:streamingAdd a web form
Section titled “Add a web form”The native HTML and React examples show the same coffee form. Choose native HTML for fewer dependencies, or React to fit an existing React application. React and Tailwind helpers currently require the source checkout.
For native HTML:
npm run start:native-uiFor React:
npm run start:react-uiRead the native HTML example or the React example.
Share a report store between two processes
Section titled “Share a report store between two processes”Two local servers use the same SQLite store. Repeating a report request with the same request ID creates one stored report. This does not guarantee exactly-once changes to an external service or support multiple computers.
npm run start:multi-instance