mcp-ts-minimal-scaffold
A skeletal implementation of a Model Context Protocol (MCP) listener in TypeScript, featuring a rudimentary body mass index calculation utility and input schema assertion via the Zod library. It facilitates interaction over conventional standard input/output streams, serving as a barebones blueprint for bespoke MCP utilities.
Author

ChenReuven
Quick Info
Actions
Tags
Minimal MCP TypeScript Blueprint
This repository furnishes a lean TypeScript blueprint engineered for bootstrapping Model Context Protocol (MCP) service endpoints. It lays the groundwork for fabricating specialized MCP apparatuses designed for integration within advanced artificial intelligence ecosystems.
Conceptual Outline
This template embodies a rudimentary MCP host environment showcasing a trivial BMI computation module. Key demonstrations include:
- Establishing an MCP host environment using TypeScript
- Designating and realizing MCP operations complete with input validation leveraging Zod
- Connecting the host service to system standard I/O channels for bidirectional data exchange
Prerequisites
- Node.js runtime (version 20 or newer strongly suggested)
- Package management tools: npm or yarn
Setup Instructions
- Acquire a local copy of this repository via cloning
- Install requisite external packages:
bash npm install
Directory Organization
index.ts- Primary service orchestration logic containing the initial sample toolpackage.json- Manifest detailing project dependencies and execution scriptstsconfig.json- TypeScript compiler configuration settings
Operational Guidance
Compilation and Launch
Initiate the build process and start the host service:
bash npm start
This command compiles the source TypeScript files into executable JavaScript and subsequently activates the MCP service listener.
Iterative Development
For active development cycles, developers may opt to:
- Modify the contents of
index.tsto incorporate novel functional operations - Execute the build directive for compilation:
bash npm run build
Implementing Novel Operations
To introduce a fresh operational capability, adhere to this structural template within index.ts:
typescript server.tool( "your-new-function-name", { // Define parameter contracts utilizing Zod assertions inputFieldLabel: z.number().min(1), // Integrate additional required fields as necessary }, async ({ inputFieldLabel }) => ({ content: [{ type: "text", text: "The outcome generated by your bespoke operation" }] }) );
Required Dependencies
@modelcontextprotocol/sdk- Essential framework components for MCP interactionzod- Library utilized for rigorous input schema verificationdotenv- Utility for managing environment variablestypescript- The language compiler itself
Licensing
ISC License
Contribution Guidelines
We welcome external input! Feel empowered to submit a Pull Request detailing your enhancements.
