- Home
- MCP servers
- Learn MCP by Building
Learn MCP by Building
- javascript
0
GitHub Stars
javascript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Model Context Protocol (MCP) lets your AI tools connect to external data sources and perform actions through a standardized, extensible interface. With MCP, you can list available tools, invoke them with parameters, and receive structured results and errors in a consistent format, enabling rich tool integration for AI assistants.
How to use
You use MCP by running an MCP-compatible server locally or remotely and then connecting with an MCP client. Depending on how you prefer to run it, you can operate through a local STDIO server for direct process I/O interactions or through an HTTP+SSE server for network-based access. Once connected, you can list available tools, call tools with the required arguments, and view results and logs in real time.
How to install
Prerequisites: install Node.js 20.x or later and a package manager such as npm or pnpm.
-
Clone the project and navigate into it.
-
Install dependencies.
Running the Examples
STDIO Server and Client; run the STDIO server with a local process and test with a local client.
npm run server:stdio
# or
node src/examples/stdio-server.js
Running HTTP+SSE Server and Client
HTTP+SSE server exposes an MCP endpoint over HTTP; test with the corresponding client. The web-based client interface is available when the server is running.
npm run server:sse
# or
node src/examples/http-sse-server.js --port 5000
Available options:
--portto specify the listening port (default: 5000)--hostto bind to a host (default: localhost)--pathendpoint path (default: /sse)--corsenable CORS (default: true)--serve-staticserve static files from src/examples/public (default: true)
## Using the MCP Inspector
Use the MCP Inspector to debug and visualize server activity. Start the inspector, then connect your MCP server to gain a visual interface for monitoring messages and tool interactions.
npm run debug
The MCP Inspector provides a visual interface for monitoring and debugging MCP servers.
Calculator Tool
The Calculator tool supports basic arithmetic operations and exposes the following parameters and error cases.
Operations: add, subtract, multiply, divide.
Parameters: operation, a, b.
Error Handling: division by zero, invalid operations, type validation, missing parameters.
Available tools
calculator
A calculator tool that performs add, subtract, multiply, and divide operations with parameters a, b, and operation. It includes error handling for division by zero, invalid operations, type validation, and missing parameters.