mcp-first-server
by Esaban17
README.md
# mcp-first-server
Primer servidor MCP (Model Context Protocol) en TypeScript, siguiendo la actividad
[First Server](https://softchris.github.io/mcp-workshop/docs/mcp-concepts/first-server/activity-first-server/)
del MCP Workshop.
Expone dos capacidades sobre transporte **stdio**:
| Tipo | Nombre | Descripción |
|---|---|---|
| Tool | `add` | Suma dos números (`a`, `b`) y devuelve el resultado como texto |
| Resource | `greeting://{name}` | Devuelve `Hello, {name}!` |
## Requisitos
- Node.js 18+ (probado con v25)
- npm
## Instalación
```bash
npm install
npm run build
```
## Probarlo con el Inspector
```bash
npm run inspector
```
Abre la interfaz web del MCP Inspector, donde puedes listar y ejecutar la tool `add`
y leer el resource `greeting://{name}`.
## Probarlo desde la terminal
Sin inspector, hablando JSON-RPC directo por stdio:
```bash
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"0"}}}\n{"jsonrpc":"2.0","method":"notifications/initialized"}\n{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"add","arguments":{"a":2,"b":3}}}\n{"jsonrpc":"2.0","id":3,"method":"resources/read","params":{"uri":"greeting://Mundo"}}\n' | node build/index.js
```
Salida esperada (entre otras líneas):
```json
{"result":{"content":[{"type":"text","text":"5"}]},"jsonrpc":"2.0","id":2}
{"result":{"contents":[{"uri":"greeting://Mundo","text":"Hello, Mundo!"}]},"jsonrpc":"2.0","id":3}
```
## Conectarlo a un cliente MCP
Ejemplo de configuración (Claude Desktop, VS Code, etc.):
```json
{
"mcpServers": {
"demo": {
"command": "node",
"args": ["/ruta/absoluta/a/mcp-first-server/build/index.js"]
}
}
}
```
## Estructura
```
src/index.ts código del servidor
tsconfig.json compila src/ -> build/
build/ salida compilada (no versionada)
```
TDQS
D1.6/5.0
Scored across 1 tool
Disambiguation5/5
With only one tool, there is no risk of confusing it with another tool. The tool is uniquely identifiable even without a description.
Naming Consistency5/5
A single tool named 'add' introduces no naming conflicts or mixed conventions. Consistency is trivially maintained.
Tool Count1/5
A server exposing exactly one tool with no description is an extreme mismatch—there is no meaningful tool surface to serve a coherent purpose.
Completeness1/5
The tool 'add' without a description or supporting tools provides no discernible domain coverage. The surface is severely incomplete and effectively useless for real tasks.
Maintenance
ActivityMaintained
ResponsivenessNo issues