MCP - Model Context Protocol

by AdiGo22

241 downloads
Not rated
GitHub

About

MCP Server using TypeScript and JavaScript made with official MCP docs handling US Weather data having context for two tools - showing weather forecast and weather alerts for US based location. Used Zod for data validation and architectured two folders - src and build , developme

Details

Author
AdiGo22
Downloads
241
Categories
Media, AI

- Open standard for AI-data connections
- Client-server architecture with multiple server support
- Supports Resources, Tools, and Prompts
- TypeScript source compiled to production JavaScript
- Communicates with Claude Desktop via stdio
- Host application can connect to multiple servers

Developers write TypeScript code in the src/ directory, implementing MCP protocol handlers (Resources, Tools, Prompts), compile it to JavaScript in the build/ directory using the TypeScript compiler, then run it via node build/index.js. Claude Desktop interacts with the server over stdio, where the flow is: Claude Desktop ↔ stdio ↔ Server Transport ↔ McpServer ↔ Tools.

MCP - Model Context Protocol

About MCP

The Model Context Protocol (MCP) is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools. The architecture is straightforward: developers can either expose their data through MCP servers or build AI applications (MCP clients) that connect to these servers.

👉 Learn more

---

MCP follows a client-server architecture where a host application can connect to multiple servers.

---

Architecture

src/ → TypeScript source
build/ → Compiled JavaScript


bash
weather/
├── src/ # TypeScript source
│ └── index.ts
├── build/ # Compiled JavaScript
│ └── index.js
├── tsconfig.json
└── package.json

---

src/ Directory (TypeScript Source)

Purpose:

- Contains development-time code written in TypeScript
- You implement MCP protocol handlers here (Resources, Tools, Prompts)
- Also contains logic, type definitions, SDKs, etc.

Key Files:

- index.ts → Entry point for your MCP server
- MCP concepts:
- resources/ → MCP Resource implementations
- tools/ → LLM-callable functions
- prompts/ → Prompt templates / management

---

build/ Directory (Compiled JavaScript)

Purpose:

- Holds runtime code after TS compilation
- This is the folder Claude Desktop interacts with via:
node build/index.js

Traits:

- Compiled, production-ready JavaScript
- No TS needed after this stage
- Clean deployable output

---

⚙️ Data Flow Pipeline

mermaid
graph LR
A[Developer Writes TS Code] --> B[src/index.ts]
B --> C[TypeScript Compiler tsc]
C --> D[build/index.js]
D --> E[Node.js Runtime]
E --> F[Claude Desktop IPC]
``

What Happens After index.js

Once your index.js` is ready, it flows like this:

Claude Desktop ↔ stdio ↔ Server Transport ↔ McpServer ↔ Tools (1)

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.