Skip to main content
Glama

MCP Server TypeScript

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

cd mcp-server npm install

Configuration

  1. Copy .env.example to .env:

    cp .env.example .env
  2. Edit .env with your configuration:

    SERVER_NAME=mcp-server SERVER_VERSION=1.0.0

Development

Build and run the server:

npm run build npm run dev

Testing with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.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:

    npm run build
  2. The compiled server is in build/index.js

  3. Run with:

    node build/index.js

Adding New Capabilities

New Tool

Edit src/tools/index.ts and add:

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:

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:

server.registerPrompt( 'prompt-name', { title: 'Prompt Title', description: 'Prompt description', }, async () => { return { messages: [ { role: 'user', content: { type: 'text', text: 'prompt text' }, }, ], }; } );

License

MIT

-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

A production-ready TypeScript MCP server providing basic tools (add, echo, timestamp), resources (server info, greetings, data access), and prompt templates (analyze, code-review, summarize). Serves as a foundation for building custom MCP servers with extensible architecture.

  1. Features
    1. Project Structure
      1. Installation
        1. Configuration
          1. Development
            1. Testing with Claude Desktop
              1. Available Capabilities
                1. Tools
                2. Resources
                3. Prompts
              2. Production Deployment
                1. Adding New Capabilities
                  1. New Tool
                  2. New Resource
                  3. New Prompt
                2. License

                  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