Telescope
Developing
MCP Integration

Telescope MCP Server Integration

Telescope now supports generating MCP (Model Context Protocol) servers for each codegen output package. This allows AI agents to interact with blockchain functionality through a standardized interface while having access to the complete telescope-generated codebase for reference.

🛠️ This is for generating a custom MCP Server with Telescope (opens in a new tab). Looking for the Hyperweb MCP Server (opens in a new tab)?
Use the MCP integration guide (opens in a new tab) to get started.

Overview

When enabled, Telescope will generate an MCP server package alongside your regular TypeScript clients. This MCP server provides:

  • Function generator tool for creating custom blockchain functions
  • Production examples as reference patterns for implementation
  • AI prompts for usage guidelines and best practices

Configuration

Add the mcpServer option to your telescope configuration:

const config = {
  mcpServer: {
    enabled: true
  },
  // ... other telescope options
}

Options

  • enabled: Boolean to enable/disable MCP server generation

When enabled, Telescope will generate a complete MCP server package with the entire telescope codebase included for reference.

Generated Structure

For each codegen package (e.g., my-chain), telescope generates a companion MCP server:

my-chain-mcp/
├── package.json              # Ready-to-publish npm package
├── tsconfig.json             # TypeScript configuration
├── README.md                 # Usage instructions
└── src/
    ├── my-chain/         # 📚 Telescope generated code (primary reference, excluded from build)
    │   ├── cosmos/           # Full cosmos SDK modules
    │   ├── osmosis/          # Osmosis DEX functionality
    │   ├── ibc/              # Inter-blockchain communication
    │   └── index.ts          # Main exports
    ├── my-chain-examples/ # 📖 Production examples (excluded from build)
    │   ├── config-example.ts # Chain configuration setup
    │   ├── useBalance.ts     # Balance query examples
    │   ├── useStaking.ts     # Staking operations
    │   ├── useVoting.ts      # Governance examples
    │   └── ...               # Additional examples
    ├── prompts/              # 🤖 Agent instruction files
    │   ├── codegen-usage.md  # Implementation guide for agents
    │   └── agent-guidelines.md # Best practices for agents
    └── index.ts              # MCP server entry point

Usage

1. Build and Install

After generation, build and install the MCP server:

cd my-chain-mcp
npm install
npm run build    # Compiles only the MCP server code (my-chain/ is excluded)

2. Configure AI Agents

Add the MCP server to your AI agent configuration:

For Cursor:

{
  "mcpServers": {
    "my-chain-mcp-server": {
      "command": "node",
      "args": ["/absolute-path/dist/index.js"]
    }
  }
}

For Claude Desktop:

{
  "mcpServers": {
    "my-chain-mcp-server": {
      "command": "node",
      "args": ["/absolute-path/dist/index.js"]
    }
  }
}

3. AI Agent Interactions

Once configured, AI agents can use the function generator tool:

AI: "Create a function to query account balance for cosmos chain"
MCP Server: Provides implementation guidance with relevant examples and patterns

AI: "I need a React hook for staking rewards on osmosis"
MCP Server: Returns step-by-step instructions using useStaking.ts as reference

AI: "Show me how to build a transaction sender"
MCP Server: Guides through implementation using transaction examples

Generated Tool

The MCP server provides a single function generator tool that uses your package codebase as reference:

Function Generator Tool

  • use-my-chain: Analyzes requests and provides step-by-step implementation guidance
  • How it works:
    1. Analyzes your task and requirements
    2. Finds relevant examples from my-chain-examples/ directory
    3. Provides implementation patterns using my-chain/ codebase as primary reference
    4. Shows proper imports, configuration, and error handling
  • Parameters:
    • task: The blockchain operation to implement (e.g., "get balance", "check staking rewards")
    • chainName: Target blockchain (e.g., cosmos, osmosis, injective)
    • functionType: Type of function (query, transaction, react-hook, utility)
    • customRequirements: Additional specifications

Development and Testing

MCP Inspector

Test your generated MCP server:

cd my-chain-mcp
npm run inspector

This opens the MCP Inspector for interactive testing of the function generator tool.

Extending Examples

You can enhance the AI agent's knowledge by adding more examples to the my-chain-examples/ directory:

cd my-chain-mcp/src/my-chain-examples
# Add your custom implementation examples

Benefits of adding examples:

  • Better guidance: AI agents will have more patterns to reference
  • Custom use cases: Add examples specific to your project needs
  • Improved accuracy: More examples help the function generator provide better recommendations

The function generator tool automatically scans the my-chain-examples/ directory, so new examples will be available immediately for AI agents to reference.

Summary of Steps

  1. Build the MCP server: npm run build in your generated package
  2. Configure your AI agent: Add the server to your MCP configuration if has not been added yet
  3. Use the function generator: Ask your AI to create blockchain functions using the examples
  4. Extend with custom examples: Add more examples to the my-chain-examples/ directory for specialized use cases

The MCP server provides a foundation for AI-assisted blockchain development with telescope-generated code.