Skip to main content
Glama
IrMaho

Antigravity Base MCP Server

by IrMaho

πŸš€ Antigravity Base MCP Server Template (Model Context Protocol Starter Kit)

An enterprise-grade, clean, and extensible Base MCP (Model Context Protocol) Server Template built with TypeScript, Zod, Vite, and Vitest.

Designed to be your foundational starter kit: whenever you need a new MCP server with custom tools for a new project, simply copy this directory, define your tools in src/tools/, and use it instantly across Claude Desktop, Google Antigravity, Cursor, and VS Code.


⚑ Autonomous On-Demand Auto-Start (Zero Manual Startup)

TIP

No Manual Startup Required! You do NOT need to manually launch, keep terminal windows open, or run background daemons for this MCP server.

  • When an AI Agent (Claude, Antigravity, Cursor) sends its first request, the client automatically spawns bin/mcp-server.js on-demand over Stdio.

  • Self-Healing Bootstrap: If node_modules/ or dist/ is missing, the launcher automatically runs npm install and compiles the project on the fly in milliseconds before handling the request!


Related MCP server: MCP Server Boilerplate

🌟 Key Features & Capabilities

  • ⚑ Strict Protocol Compliance: Implements MCP Specification 2024-11-05 and JSON-RPC 2.0 (initialize, ping, tools/list, tools/call, resources/list, resources/read, prompts/list, prompts/get, completion/complete).

  • πŸ›‘οΈ Zero Stdout Pollution: Clean Stdio transport with all logger output strictly routed to stderr and optional file logging.

  • 🧩 Modular Tool Architecture: Abstract BaseTool class with automatic Zod schema-to-JSON-Schema conversion and safe runtime validation.

  • πŸ› οΈ Instant Tool Generator: Run npm run new-tool <tool_name> to scaffold a new tool with types and schema in seconds.

  • πŸ§ͺ Complete Test Suite: Integrated Vitest unit tests and real-stdio end-to-end integration tests (npm run test:all).

  • πŸ–₯️ Windows 1-Click Automation: .bat files for installation, building, testing, and running.

  • πŸ“– Bilingual Guides: Includes English and comprehensive Persian documentation (GUIDE_FA.md).


πŸ“Š Why Use This Base MCP Instead of Building from Scratch?

Comparison Criteria

Building from Scratch (From 0)

Using Antigravity Base MCP

Setup Time

2 to 4 hours of tedious boilerplate

Under 1 minute (copy folder & rename)

Stdio Stream Corruption

High risk (console.log breaks JSON-RPC)

100% Protected with stderr-isolated Logger

Parameter Validation

Manual, error-prone JSON Schema definitions

Type-safe Zod Schemas with auto JSON Schema conversion

Server Lifecycle

Manual script startup and background management

Autonomous on-demand wake-up and auto-build

Error Handling

Repetitive try/catch boilerplate per tool

Standardized error wrappers with detailed diagnostics

Testability

Hard to test without full LLM client

Built-in CLI & Vitest for immediate isolated testing

Multi-Client Support

Unpredictable protocol quirks

Battle-tested across Claude, Antigravity, Cursor


πŸ—οΈ Foundational Capabilities for Future Expansion

This template gives you the complete architecture to build:

  1. πŸ—„οΈ Database MCPs: Connect to SQLite, PostgreSQL, MongoDB, or Redis and expose query tools to AI agents.

  2. πŸ“± Flutter / Dart MCPs: Expose AST analyzers, automated widget generators, and emulator controllers.

  3. πŸ’» OS & File Automation MCPs: Create secure file management, process execution, and system diagnostics tools.

  4. 🌐 API Gateway & Webhook MCPs: Integrate third-party APIs, payments, messaging bots, and internal microservices.

  5. πŸ“„ Dynamic Resources: Expose live project state, documentation, and database schemas directly to agents.

  6. πŸ’‘ Prompt Engineering Templates: Provide structured multi-step reasoning prompts for refactoring and security reviews.


πŸ“ Directory Structure

base_mcp/
β”œβ”€β”€ .agents/
β”‚   └── skills/
β”‚       └── base-mcp-starter/
β”‚           └── SKILL.md            # AI Agent skill documentation
β”œβ”€β”€ bin/
β”‚   β”œβ”€β”€ cli.ts                      # Interactive Developer CLI
β”‚   β”œβ”€β”€ mcp-server.ts               # Direct TS runner
β”‚   └── mcp-server.js               # Autonomous zero-config Node runner
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts                    # Main library exports
β”‚   β”œβ”€β”€ server.ts                   # Core BaseMCPServer JSON-RPC router
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── index.ts                # Server configuration & environment
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ types.ts                # Protocol types
β”‚   β”‚   β”œβ”€β”€ logger.ts               # Stderr / file logger
β”‚   β”‚   β”œβ”€β”€ errors.ts               # JSON-RPC error codes & classes
β”‚   β”‚   └── transport.ts            # Stdio transport engine
β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”œβ”€β”€ base-tool.ts            # Abstract base tool with Zod parsing
β”‚   β”‚   β”œβ”€β”€ registry.ts             # Central tool registry
β”‚   β”‚   β”œβ”€β”€ index.ts                # Tool registry loader & registrations
β”‚   β”‚   └── examples/
β”‚   β”‚       β”œβ”€β”€ echo.tool.ts        # Echo sample tool
β”‚   β”‚       β”œβ”€β”€ system-info.tool.ts # System diagnostics sample tool
β”‚   β”‚       └── custom-template.tool.ts # Copy-paste blueprint
β”‚   β”œβ”€β”€ resources/
β”‚   β”‚   β”œβ”€β”€ index.ts                # Resource manager
β”‚   β”‚   └── examples/
β”‚   β”‚       └── sample-resource.ts  # Sample dynamic resource
β”‚   └── prompts/
β”‚       β”œβ”€β”€ index.ts                # Prompt manager
β”‚       └── examples/
β”‚           └── sample-prompt.ts    # Sample prompt template
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ create-tool.ts              # Tool scaffolding generator
β”‚   β”œβ”€β”€ test-stdio.ts               # End-to-end stdio protocol tester
β”‚   └── export-schemas.ts           # Schema exporter to JSON files
β”œβ”€β”€ templates/
β”‚   └── mcp_config.example.json     # Client configuration snippets
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ server.test.ts              # Server protocol tests
β”‚   └── tools.test.ts               # Tool execution tests
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vite.config.ts
β”œβ”€β”€ vitest.config.ts
β”œβ”€β”€ Build.bat
β”œβ”€β”€ Run-Tests.bat
β”œβ”€β”€ Start-Server.bat
└── Install-Dependencies.bat

⚑ Quick Start

1. Install Dependencies

npm install
# or double click Install-Dependencies.bat

2. Build the Server

npm run build
# or double click Build.bat

3. Run Automated Tests

npm run test:all
# or double click Run-Tests.bat

4. Test Interactive CLI

# List all registered tools:
npm run cli list

# Call a tool directly:
npm run cli call echo '{"message": "Hello World!", "repeat": 2}'

πŸ› οΈ How to Create a New Tool in 3 Steps

Step 1: Generate Scaffolding

npm run new-tool calculate_tax

This generates src/tools/calculate-tax.tool.ts.

Step 2: Define Schema & Implement Logic

Open src/tools/calculate-tax.tool.ts:

import { z } from 'zod';
import { BaseTool } from './base-tool';
import { MCPToolCallResult } from '../core/types';

export const CalculateTaxSchema = z.object({
  amount: z.number().positive().describe('Total amount in USD'),
  taxRate: z.number().min(0).max(1).default(0.09).describe('Tax rate decimal (e.g. 0.09 for 9%)'),
});

export type CalculateTaxInput = z.infer<typeof CalculateTaxSchema>;

export class CalculateTaxTool extends BaseTool<typeof CalculateTaxSchema> {
  public readonly name = 'calculate_tax';
  public readonly description = 'Calculates total tax and grand total for a given amount.';
  public readonly schema = CalculateTaxSchema;

  public async execute(args: CalculateTaxInput): Promise<MCPToolCallResult> {
    const tax = args.amount * args.taxRate;
    const total = args.amount + tax;

    return this.jsonResult({
      originalAmount: args.amount,
      taxRate: args.taxRate,
      taxAmount: Math.round(tax * 100) / 100,
      grandTotal: Math.round(total * 100) / 100,
    });
  }
}

Step 3: Register in src/tools/index.ts

import { CalculateTaxTool } from './calculate-tax.tool';

export function createDefaultToolRegistry(): ToolRegistry {
  const registry = new ToolRegistry();
  
  // Register your new tool:
  registry.register(new CalculateTaxTool());

  return registry;
}

Rebuild (npm run build) and test:

npm run cli call calculate_tax '{"amount": 100, "taxRate": 0.15}'

πŸ”Œ Connecting to AI Clients

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "my-mcp": {
      "command": "node",
      "args": ["C:/Users/ASUS/Desktop/flutter_project/base_mcp/bin/mcp-server.js"]
    }
  }
}

Google Antigravity / Gemini CLI (mcp_config.json)

{
  "mcpServers": {
    "my-mcp": {
      "command": "node",
      "args": ["C:/Users/ASUS/Desktop/flutter_project/base_mcp/bin/mcp-server.js"],
      "env": {
        "MCP_LOG_LEVEL": "info"
      }
    }
  }
}

Cursor IDE (.cursor/mcp.json)

{
  "mcpServers": {
    "my-mcp": {
      "command": "node",
      "args": ["C:/Users/ASUS/Desktop/flutter_project/base_mcp/bin/mcp-server.js"]
    }
  }
}

πŸ“œ License

MIT License. Created by Antigravity Engineering.

Available Tools

3 tools
echoA

Echoes back the input message with optional repetition and prefix formatting.

ParametersJSON Schema
NameRequiredDescriptionDefault
prefixNoOptional prefix to prepend to each line
repeatNoNumber of times to repeat the message
messageNoThe text message to echo back

TDQS

A4.2/5.0
Behavior4/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. It discloses the core behavior (echoing back input) and the optional modifiers (repetition, prefix). It does not cover edge cases like zero or negative repetition, but for a simple echo tool this is adequate. It adds meaningful behavioral context beyond the schema.

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?

A single, efficient sentence that front-loads the core action and mentions the two optional modifiers. No wasted words.

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

Completeness4/5

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

For a tool with no output schema and a trivial return value, the description is sufficient. It explains the action and the parameters' purpose. Minor gaps like default behavior of repeat or prefix concatenation rules are not critical for an echo tool.

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

Parameters3/5

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

Schema description coverage is 100% – each parameter already has a clear description. The tool description's mention of 'optional repetition and prefix formatting' merely reiterates the schema. It adds no new semantic detail, so the baseline of 3 applies.

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

Purpose5/5

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

The description states a clear verb ('echoes back'), a specific resource ('the input message'), and the optional behaviors (repetition and prefix formatting). It is unambiguous and naturally distinguished from the sibling tools, which are unrelated in function.

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

Usage Guidelines4/5

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

The description does not explicitly mention when to use this tool vs alternatives, but the siblings (get_system_info, my_custom_tool) are so different in purpose that no exclusion is necessary. The context is clear, though not explicitly stated.

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

get_system_infoA

Retrieves current system diagnostics including OS, Node version, memory, and CPU info.

ParametersJSON Schema
NameRequiredDescriptionDefault
includeCpuNoWhether to include CPU architecture details
includeMemoryNoWhether to include memory statistics

TDQS

A3.5/5.0
Behavior3/5

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

No annotations are provided, so the description must disclose behavioral traits. It implies a read-only operation ('Retrieves') but does not describe the return format, potential side effects, or error conditions. It adds minimal context beyond the obvious.

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 sentence that front-loads the main action and lists the key content. It is concise with no redundant information.

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?

For a simple diagnostic tool with no output schema, the description adequately states what it does but lacks usage context, output format, and any caveats. Given the low complexity, a 3 is reasonable, but it could be improved with a note on when to use it or what the response structure looks like.

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

Parameters3/5

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

The schema covers both parameters (includeCpu and includeMemory) with clear descriptions. The description mentions memory and CPU, aligning with the parameters, but does not add any extra meaning such as defaults, dependencies, or impact of omitting them. Baseline 3 is appropriate since schema coverage is 100%.

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

Purpose5/5

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

The description clearly states the tool retrieves system diagnostics, listing specific contents (OS, Node version, memory, CPU). It is specific and unambiguous, and the sibling names (echo, my_custom_tool) suggest they serve different purposes, so the distinction is implicit.

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 does not provide any guidance on when to use this tool versus alternatives, nor does it mention any conditions, prerequisites, or exclusions. It simply states what it does without contextual routing.

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

my_custom_toolD

Detailed description of what this tool accomplishes, its expected input, and its output format.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of items to return
queryNoSearch query or target input string
optionsNoOptional execution configuration

TDQS

D1.4/5.0
Behavior1/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. The placeholder text does not disclose any side effects, permissions, rate limits, or return behavior. It merely states that a description exists, offering no substantive information about what the tool does or what happens when called.

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

Conciseness2/5

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

The description is a single generic sentence, but it is not concise in the sense of conveying useful informationβ€”it is under-specified and content-free. It is a placeholder template, not an efficient communication of tool behavior. This resembles the under-specification case rather than true conciseness.

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

Completeness1/5

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

The tool has a nested object and three parameters, yet no output schema and no description of purpose or return format. The placeholder leaves the agent completely in the dark about what the tool does, what it returns, or how it relates to siblings. The definition is fundamentally incomplete for any real usage.

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

Parameters3/5

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

Schema description coverage is 100%, so the input schema already documents all parameters (limit, query, options). According to the rubric, a high coverage baseline of 3 applies. The description adds no value beyond the schema, but it does not need to compensate since the schema is thorough.

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

Purpose1/5

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

The description is a generic placeholder: 'Detailed description of what this tool accomplishes, its expected input, and its output format.' It provides zero actual information about the tool's function, resource, or scope. It is neither a specific verb+resource nor a restatement of the name; it is simply a template sentence that fails to convey any purpose.

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

Usage Guidelines1/5

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

No guidance is given on when to use this tool versus its siblings (echo, get_system_info). The description contains no context about intended scenarios, prerequisites, or exclusions. An agent has no basis to decide whether to select this tool over alternatives.

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.

  1. 3 tool updatesv1.0.0
    • First observedecho
    • First observedget_system_info
    • First observedmy_custom_tool

TDQS

C2.5/5.0

Scored across 3 tools

Disambiguation4/5

echo and get_system_info are clearly distinct operations, and my_custom_tool is not described in a way that directly overlaps with them. However, the placeholder description for my_custom_tool leaves its actual purpose ambiguous, so the set is not perfectly unambiguous.

Naming Consistency2/5

The naming is inconsistent: echo uses a bare verb, get_system_info follows verb_noun, and my_custom_tool uses a vague custom label. There is no shared naming convention across the three tools.

Tool Count3/5

Three tools is not an unreasonable number by itself, but the set feels like a minimal scaffold rather than a focused server. The unrelated utilities and placeholder custom tool make the count less defensible than it would be with a clear shared purpose.

Completeness2/5

The server lacks a coherent domain, so it is difficult to determine what complete coverage would look like. echo and get_system_info are isolated utilities, while my_custom_tool is an unspecified placeholder, leaving obvious gaps in any implied workflow.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A starter template for building MCP servers with TypeScript support, example tools, and automated installation scripts for Claude Desktop, Cursor, and other MCP-compatible AI assistants. Provides a foundation for creating custom tools, resource providers, and prompt templates.
    32 npm
    -
  • F
    license
    B
    quality
    D
    maintenance
    A starter template for building custom MCP servers that can integrate with Claude Desktop, Cursor, and other AI assistants. Provides example tools, TypeScript support, and automated publishing workflows to help developers quickly create their own MCP integrations.
    1
    5 npm
    -
  • F
    license
    A
    quality
    C
    maintenance
    A starter template for building custom MCP servers that can integrate with Claude Desktop, Cursor, and other AI assistants. Provides example tools, TypeScript support, and automated publishing workflows to help developers quickly create their own MCP servers.
    7
    4 npm
    -
  • F
    license
    C
    quality
    D
    maintenance
    A starter template for building custom MCP servers that can integrate with Claude, Cursor, or other MCP-compatible AI assistants. Provides a clean foundation with TypeScript support, example implementations, and easy installation scripts for quickly creating tools, resources, and prompt templates.
    2
    3 npm
    -