About MCP Quick Start Server
MCP Quick Start Server is a TypeScript example for developers learning to build MCP servers. It demonstrates tools, a resource, and a prompt through a small Node.js project.
Key features
- 01TypeScript MCP server setup
- 02Add two numbers with a tool
- 03Fetch a random Chuck Norris joke
- 04Personalized greeting resource
- 05Greeting-and-joke prompt
Use cases
- 01Learning basic MCP server structure
- 02Testing tool, resource, and prompt registration
- 03Developing a Node.js MCP project
MCP support
Implements an MCP server using the TypeScript SDK and communicates with clients over standard input and output. It exposes two tools, a greeting resource, and a prompt.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Quick Start Server
This project is a simple quick-start example of a Model Context Protocol (MCP) server built with TypeScript and the @modelcontextprotocol/sdk. It demonstrates how to define basic tools, resources, and prompts.
Features
- Tool:
add: Adds two numbers.- Parameters:
a(number),b(number) - Returns: The sum as a string.
- Parameters:
- Tool:
fetch-chuck-jokes: Fetches a random Chuck Norris joke.- Parameters: None
- Returns: A Chuck Norris joke as a string.
- Resource:
greeting: Provides a personalized greeting.- URI Scheme:
greeting://{name} - Example:
greeting://Worldwould provide a greeting for "World".
- URI Scheme:
- Prompt:
getGreetingAndJoke: Instructs an AI client to greet a user by name and then tell them a Chuck Norris joke.- Parameter:
name(string) - Example: Invoking with
name: "Narendra"will set up a conversation for the AI to greet Narendra and tell a joke.
- Parameter:
Directory Structure
quick-start/
├── build/ # Compiled JavaScript output
├── src/ # TypeScript source files
│ ├── index.ts # Main server setup and entry point
│ ├── tools/
│ │ └── index.ts # Tool definitions
│ ├── resources/
│ │ └── index.ts # Resource definitions
│ └── prompts/
│ └── index.ts # Prompt definitions
├── .gitignore
├── package-lock.json
├── package.json
├── tsconfig.json
└── README.md # This file
Prerequisites
Setup & Installation
-
Clone the repository (if you haven't already):
git clone https://github.com/scriptstar/mcp-starter-kit-node.git cd mcp-starter-kit-node -
Install dependencies:
npm install
Building the Server
To compile the TypeScript code into JavaScript, run:
npm run build
This command executes tsc (the TypeScript compiler) according to the tsconfig.json configuration and places the output in the build/ directory. It also makes the main build file executable.
Running the Server
Once built, you can start the MCP server using:
node build/index.js
Alternatively, for production-like environments, you can use the start script:
npm start
The server will start and listen for messages on standard input (stdin) and send responses to standard output (stdout), as it uses the StdioServerTransport.
Development Workflow
For a more efficient development experience, you can use the dev script:
npm run dev
This command uses concurrently to run two processes:
tsc -w: Watches your TypeScript files for changes and recompiles them automatically.nodemon build/index.js: Watches for changes in thebuilddirectory (wheretscoutputs JavaScript) and restarts the Node.js server automatically.
This provides a live-reload-like experience during development.
Linting
This project uses ESLint with TypeScript support to maintain code quality and consistency.
- To check for linting errors:
npm run lint - To automatically fix fixable linting errors:
npm run lint:fix
It's recommended to run the linter before committing code.
How It Works
This server implements the Model Context Protocol.
src/index.ts: Initializes anMcpServerinstance, imports tool, resource, and prompt registration functions from their respective modules, calls these functions to register them with the server, and then connects aStdioServerTransportto handle communication.src/tools/index.ts: Exports aregisterToolsfunction.add: Takes two numbersaandband returns their sum.fetch-chuck-jokes: Makes an HTTP GET request tohttps://api.chucknorris.io/jokes/randomand returns the joke.
src/resources/index.ts: Exports aregisterResourcesfunction.greeting: Defines a resource templategreeting://{name}. When this URI is requested, it returns a personalized greeting message.
src/prompts/index.ts: Exports aregisterPromptsfunction.getGreetingAndJoke: Defines a prompt that takes anameargument. It constructs a set of initial messages to guide an AI client. The first message (role: assistant) sets the context, and the second message (role: user) formulates the request using the providedname.
Interacting with the Server (Conceptual)
This MCP server is designed to be controlled by an MCP client (e.g., an AI assistant, a development tool). The client communicates with the server by sending JSON-RPC messages to its stdin and receiving responses from its stdout.
Here's how a client might interact with the defined capabilities:
-
Calling the
addtool: A client could send a JSON-RPC request like:{ "jsonrpc": "2.0", "method": "callTool", "params": { "name": "add", "args": { "a": 5, "b": 3 } }, "id": "request1" }The server would respond with the result:
{ "jsonrpc": "2.0", "result": { "content": [{ "type": "text", "text": "8" }] }, "id": "request1" } -
Accessing the
greetingresource: A client could request to read the resource URIgreeting://Alice:{ "jsonrpc": "2.0", "method": "readResource", "params": { "uri": "greeting://Alice" }, "id": "request2" }The server would respond:
{ "jsonrpc": "2.0", "result": { "contents": [{ "uri": "greeting://Alice", "text": "Hello, Alice!" }] }, "id": "request2" } -
Using the
getGreetingAndJokeprompt: A client wanting to initiate this guided task for "Bob" would send:{ "jsonrpc": "2.0", "method": "getPrompt", "params": { "uri": "prompt://getGreetingAndJoke", "args": { "name": "Bob" } }, "id": "request3" }The server would respond with the initial messages:
{ "jsonrpc": "2.0", "result": { "messages": [ { "role": "assistant", "content": { "type": "text", "text": "You are a friendly assistant. Your task is to greet the user by their name and then tell them a Chuck Norris joke. You should use the available tools and resources to accomplish this. I will now wait for your instruction to proceed with greeting and joke telling for the specified user." } }, { "role": "user", "content": { "type": "text", "text": "Please greet Bob and then tell a Chuck Norris joke." } } ] }, "id": "request3" }The AI client would then process these messages and subsequently decide to call the
greetingresource (for "Bob") and thefetch-chuck-jokestool, using separatereadResourceandcallToolrequests.
Further Development
- Add more complex tools with various input/output types.
- Implement resources that interact with local files or databases.
- Create more sophisticated prompts for multi-turn conversations.
- Explore other transport layers (e.g., HTTP) if needed.
- Add comprehensive error handling and logging.
This README should give a good overview of your project!
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.