Skip to main content
Glama

MCP Server TypeScript

README.md3.55 kB
# MCP Server - TypeScript A production-ready Model Context Protocol (MCP) server built with TypeScript. ## Features - **Tools**: Execute actions (add, echo, timestamp) - **Resources**: Access data (server info, greetings, data by ID) - **Prompts**: Reusable prompt templates (analyze, code-review, summarize) ## Project Structure ``` mcp-server/ ├── src/ │ ├── index.ts # Main server entry point │ ├── tools/ # Tool implementations │ │ └── index.ts │ ├── resources/ # Resource handlers │ │ └── index.ts │ ├── prompts/ # Prompt templates │ │ └── index.ts │ └── utils/ # Helper functions │ └── helpers.ts ├── build/ # Compiled output (generated) ├── .env.example # Environment template ├── .gitignore ├── package.json ├── tsconfig.json └── README.md ``` ## Installation ```bash cd mcp-server npm install ``` ## Configuration 1. Copy `.env.example` to `.env`: ```bash cp .env.example .env ``` 2. Edit `.env` with your configuration: ```env SERVER_NAME=mcp-server SERVER_VERSION=1.0.0 ``` ## Development Build and run the server: ```bash npm run build npm run dev ``` ## Testing with Claude Desktop Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`): ```json { "mcpServers": { "mcp-server": { "command": "node", "args": ["/absolute/path/to/mcp-server/build/index.js"] } } } ``` ## Available Capabilities ### Tools - `add` - Add two numbers - `echo` - Echo text back - `timestamp` - Get current timestamp ### Resources - `info://server` - Server information - `greeting://{name}` - Personalized greeting - `data://{id}` - Data by ID ### Prompts - `analyze` - Analysis prompt template - `code-review` - Code review prompt template - `summarize` - Summarization prompt template ## Production Deployment 1. Build the project: ```bash npm run build ``` 2. The compiled server is in `build/index.js` 3. Run with: ```bash node build/index.js ``` ## Adding New Capabilities ### New Tool Edit `src/tools/index.ts` and add: ```typescript server.registerTool( 'tool-name', { title: 'Tool Title', description: 'Tool description', inputSchema: { param: z.string().describe('Parameter description'), }, }, async ({ param }) => { // Implementation return { content: [{ type: 'text', text: 'result' }], }; } ); ``` ### New Resource Edit `src/resources/index.ts` and add: ```typescript server.registerResource( 'resource-name', new ResourceTemplate('scheme://{param}', { list: undefined }), { title: 'Resource Title', description: 'Resource description', }, async (uri, { param }) => { return { contents: [{ uri: uri.href, text: 'data' }], }; } ); ``` ### New Prompt Edit `src/prompts/index.ts` and add: ```typescript server.registerPrompt( 'prompt-name', { title: 'Prompt Title', description: 'Prompt description', }, async () => { return { messages: [ { role: 'user', content: { type: 'text', text: 'prompt text' }, }, ], }; } ); ``` ## License MIT

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ichetanmittal/mcp-server-temp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server