Skip to main content
Glama
gustta03

MCP Server Template

by gustta03

MCP Server Template

Template TypeScript para criacao de servidores MCP (Model Context Protocol) usando o SDK oficial @modelcontextprotocol/sdk.

Copie este repositorio como ponto de partida para qualquer novo servidor MCP. A estrutura ja esta pronta com contrato de tool, adaptador de registro e uma tool de exemplo.


Estrutura

.
├── src/
│   ├── core/
│   │   └── protocols/
│   │       └── McpTool.ts       # Interface base para todas as tools
│   ├── adapters/
│   │   └── registerMcpTools.ts  # Registra tools no McpServer
│   ├── tools/
│   │   └── HealthTool.ts        # Tool de exemplo (health check)
│   └── main.ts                  # Bootstrap do servidor (stdio)
├── claude_desktop_config.example.json
├── package.json
└── tsconfig.json

Related MCP server: TypeScript MCP Server Boilerplate

Decisoes de arquitetura

core/protocols/McpTool.ts

Contrato que toda tool deve implementar. Desacopla as tools do SDK, tornando cada uma independente e testavel.

export interface McpTool<
  TInput extends Record<string, unknown> = Record<string, unknown>,
> {
  name: string;
  description: string;
  inputSchema: McpInputSchema; // Record<string, z.ZodTypeAny>
  execute(input: TInput): Promise<string>;
}

adapters/registerMcpTools.ts

Unico ponto que conhece o McpServer. Itera sobre as tools e faz o bind via server.registerTool, mantendo o resto do codigo desacoplado do SDK.

tools/

Cada tool e uma classe que implementa McpTool. O inputSchema usa tipos Zod para que o SDK valide e documente os parametros automaticamente.

main.ts

Bootstrap do processo. Instancia o servidor, registra as tools e conecta o transporte stdio.

Regra importante: nunca use console.log — o canal stdout e reservado para o protocolo MCP. Use sempre console.error para logs.


Rodando localmente

npm install
npm run dev

Scripts

Comando

Descricao

npm run dev

Modo desenvolvimento com hot reload (tsx)

npm run build

Compila TypeScript para build/

npm run start

Executa o servidor compilado

npm run typecheck

Valida tipos sem emitir arquivos


Como usar este template

1. Copie o repositorio

cp -r mcp-server-template ../meu-novo-mcp
cd ../meu-novo-mcp
npm install

2. Compile e execute

npm run build
node build/main.js

3. Configure o cliente MCP

Use claude_desktop_config.example.json como base:

{
  "mcpServers": {
    "meu-novo-mcp": {
      "command": "node",
      "args": ["/caminho/absoluto/para/meu-novo-mcp/build/main.js"]
    }
  }
}

Como adicionar uma nova tool

1. Crie a classe da tool em src/tools/

// src/tools/MinhaFerramenta.ts
import { z } from "zod";
import { McpTool } from "../core/protocols/McpTool.js";

export class MinhaFerramenta implements McpTool<{ mensagem: string }> {
  name = "minha_ferramenta";
  description = "Descricao do que esta tool faz.";

  inputSchema = {
    mensagem: z.string().describe("Texto de entrada"),
  };

  async execute(input: { mensagem: string }): Promise<string> {
    return JSON.stringify({ resultado: input.mensagem.toUpperCase() });
  }
}

2. Registre em src/main.ts

import { MinhaFerramenta } from "./tools/MinhaFerramenta.js";

registerMcpTools(server, [new HealthTool(), new MinhaFerramenta()]);

Dependencias

Pacote

Finalidade

@modelcontextprotocol/sdk

SDK oficial para criacao de servidores MCP

zod

Validacao e tipagem dos inputs das tools

tsx

Execucao de TypeScript sem build (dev)

typescript

Compilador TypeScript

Available Tools

1 tool
healthB

Retorna o status do servidor MCP.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns server status, implying a read-only operation, but does not specify whether it requires authentication, has rate limits, or details about the response format. The description adds minimal behavioral context beyond the basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Retorna o status do servidor MCP.' It is front-loaded with the core function, has zero wasted words, and is appropriately sized for a simple tool. Every part of the sentence contributes directly to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no annotations, no output schema), the description is adequate but has gaps. It explains what the tool does but lacks details on behavioral aspects like authentication or response format. For a status-checking tool, this is minimally viable but could be more informative about the returned data or usage constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the schema description coverage is 100% (though empty). The description does not need to add parameter semantics, as there are no inputs to explain. This meets the baseline expectation for tools without parameters, but since it doesn't explicitly state 'no parameters required,' it falls slightly short of a perfect score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Retorna o status do servidor MCP' (Returns the server MCP status). It uses a specific verb ('retorna') and resource ('status do servidor MCP'), making the function unambiguous. However, since there are no sibling tools, it cannot demonstrate differentiation from alternatives, preventing a perfect score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or context. It simply states what the tool does without indicating scenarios for its application. Since there are no sibling tools, the lack of explicit when/when-not guidance is less critical but still results in minimal guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev1.0.0
    • First observedhealth

TDQS

B3.2/5.0
Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool 'health' has a clearly distinct and singular purpose of returning server status.

Naming Consistency5/5

A single tool inherently has perfect naming consistency as there are no other tools to compare against. The name 'health' is clear and follows a simple noun pattern.

Tool Count2/5

One tool is too few for a server described as a 'template', which implies a broader scope or example set. A template should ideally demonstrate multiple tools to guide users, making this count inappropriate for the stated purpose.

Completeness1/5

The server is severely incomplete for a template purpose, as it only provides a health check tool with no other functionality. This leaves significant gaps, failing to cover any meaningful domain or provide a useful example surface.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • -
    license
    B
    quality
    Not graded
    maintenance
    A boilerplate project for quickly developing Model Context Protocol (MCP) servers using TypeScript SDK. Includes example tools for calculations and greetings, plus system information resources.
    3
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A boilerplate project for quickly developing Model Context Protocol (MCP) servers using TypeScript SDK, with example implementations of tools (calculator, greetings) and resources (server info) using Zod schema validation.
    88
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A starter kit for quickly building Model Context Protocol (MCP) servers using the TypeScript SDK. It includes a structured project setup with pre-configured examples for implementing tools, resources, and Zod-based schema validation.
    225
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A starter project designed to quickly build and deploy Model Context Protocol (MCP) servers using the TypeScript SDK and Zod for schema validation. It features example implementations for tools and resources, providing a solid foundation for custom MCP development and integration.
    -

Latest Blog Posts

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/gustta03/mcp-server-tamplate'

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