Bitso MCP Server

Bitso MCP Server

Enables interaction with the Bitso cryptocurrency exchange API to access withdrawals and fundings data. Provides comprehensive tools for listing, filtering, and retrieving withdrawal and funding transactions with proper authentication and error handling.

Category
访问服务器

README

Bitso MCP Server

An MCP server for the Bitso API that provides tools to access withdrawals and fundings data. Built with TypeScript, featuring comprehensive testing, dual transport support, and production-ready best practices.

Features

🏦 Bitso API Integration

  • Complete Withdrawals API support (list, get by ID, get by multiple IDs, get by origin IDs)
  • Complete Fundings API support (list, get by ID)
  • Proper authentication with API key/secret and HMAC signature
  • Support for all API filtering and pagination parameters

🚀 Production Ready

  • Dual transport support (stdio for Claude Desktop, HTTP for development)
  • Comprehensive error handling and logging
  • Type-safe configuration with Zod validation
  • Project-root-aware file logging system

🧪 Comprehensive Testing

  • Two-tier testing strategy (unit + integration tests)
  • Real MCP protocol testing (not mocked functions)
  • MSW for consistent API mocking
  • High test coverage with Vitest

🛠️ Developer Experience

  • Hot reloading with TypeScript watch mode
  • Tool generation script
  • ESM support with proper module resolution
  • CI/CD pipeline with GitHub Actions

📦 Best Practices

  • Modular tool organization
  • Zod schema validation for all inputs
  • Structured logging with file output
  • Caching with configurable TTL

Quick Start

1. Setup

npm install

2. Configure Environment

cp .env.example .env
# Edit .env with your Bitso API credentials

Required environment variables:

  • BITSO_API_KEY: Your Bitso API key
  • BITSO_API_SECRET: Your Bitso API secret

3. Build and Test

# Build the project
npm run build

# Run tests
npm run test

# Start development server (HTTP mode)
npm run start:http

4. Add to Claude Desktop

Add to your Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "bitso-mcp-server": {
      "command": "node",
      "args": ["/path/to/bitso-mcp-server/dist/src/index.js"],
      "env": {
        "BITSO_API_KEY": "your-bitso-api-key",
        "BITSO_API_SECRET": "your-bitso-api-secret"
      }
    }
  }
}

Available Tools

The server provides 6 tools to interact with the Bitso API:

Withdrawals Tools

  1. list_withdrawals - List withdrawals with optional filtering

    • Parameters: currency, limit, marker, method, origin_id, status, wid
  2. get_withdrawal - Get specific withdrawal by ID

    • Parameters: wid (required)
  3. get_withdrawals_by_ids - Get multiple withdrawals by comma-separated IDs

    • Parameters: wids (required, e.g., "wid1,wid2,wid3")
  4. get_withdrawals_by_origin_ids - Get withdrawals by client-supplied origin IDs

    • Parameters: origin_ids (required, e.g., "origin1,origin2,origin3")

Fundings Tools

  1. list_fundings - List fundings with optional filtering

    • Parameters: limit, marker, method, status, fids
  2. get_funding - Get specific funding by ID

    • Parameters: fid (required)

Development Guide

Project Structure

src/
├── tools/           # MCP tool implementations
│   └── bitso-tools.ts  # Bitso API tools
├── utils/           # Shared utilities
│   └── logging.ts   # Project-root-aware logging
├── client.ts        # Bitso API client with authentication
├── config.ts        # Environment configuration
├── types.ts         # TypeScript type definitions
└── index.ts         # Main server entry point

tests/
├── unit/            # Fast unit tests with MSW mocking
├── integration/     # Real MCP protocol tests
├── helpers/         # Test utilities
│   ├── mcp-test-helper.ts
│   ├── test-server-factory.ts
│   └── test-config.ts
├── mocks/           # MSW request handlers
└── setup.ts         # Test environment setup

Creating New Tools

Use the built-in tool generator:

npm run build
npm run create-tool

Or create manually following the pattern in src/tools/bitso-tools.ts:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const MyToolSchema = z.object({
  param: z.string().min(1, "Parameter is required"),
});

export function registerMyTools(server: McpServer, client: BitsoApiClient): void {
  server.tool(
    "my_tool",
    {
      description: "Description of what the tool does",
      inputSchema: {
        type: "object",
        properties: {
          param: {
            type: "string",
            description: "Parameter description",
          },
        },
        required: ["param"],
      },
    },
    async (params): Promise<ToolResult> => {
      try {
        const validatedParams = MyToolSchema.parse(params);
        
        // Your tool logic here
        
        return {
          content: [
            {
              type: "text",
              text: "Tool response"
            }
          ]
        };
      } catch (error) {
        // Error handling
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
    }
  );
}

Testing Strategy

This template uses a two-tier testing approach:

Unit Tests (tests/unit/)

  • Test business logic in isolation
  • Mock external APIs using MSW
  • Fast execution, run frequently during development
  • Focus on data transformations, caching, validation

Integration Tests (tests/integration/)

  • Test through real MCP protocol
  • Use actual MCP server instances
  • Validate tool registration and MCP compliance
  • Ensure proper request/response formatting
# Run unit tests (fast)
npm run test:unit

# Run integration tests (slower, full MCP protocol)
npm run test:integration

# Run all tests with coverage
npm run test:coverage

Transport Modes

Stdio Transport (Production)

Used by Claude Desktop and other MCP clients:

npm start
# or
node dist/src/index.js

HTTP Transport (Development)

Useful for debugging and development:

npm run start:http
# Server available at http://localhost:3000/mcp

Logging and Debugging

The template includes a sophisticated logging system:

  • Debug logs: Written to mcp-debug.log in project root
  • Project-root-aware: Works from both source and compiled code
  • Structured logging: JSON formatting for complex data
  • Console output: Errors also logged to stderr

Check logs during development:

tail -f mcp-debug.log

Configuration Management

Configuration uses Zod for type-safe validation:

// src/config.ts
const ConfigSchema = z.object({
  apiKey: z.string().min(1, 'API_KEY environment variable is required'),
  apiEndpoint: z.string().url().default('https://api.example.com'),
  // ... other config
});

Environment variables are validated on startup with clear error messages.

API Integration

Client Pattern

The template includes a robust API client pattern:

// Automatic caching
const resources = await client.getResources(); // Cached for 5 minutes

// Error handling
try {
  const resource = await client.getResource(id);
} catch (error) {
  // Errors are logged and can be handled
}

// Connection testing
const isHealthy = await client.testConnection();

Bitso API Authentication

The server uses HMAC-SHA256 authentication required by the Bitso API:

// Authentication headers are automatically generated
const authHeaders = {
  'key': config.apiKey,
  'signature': hmacSignature,  // Generated using API secret
  'nonce': timestamp
};

Each request is signed using:

  • API Secret (from environment)
  • HTTP method
  • Request path
  • Request body (if any)
  • Current timestamp as nonce

Deployment

Building for Production

npm run build
npm test

CI/CD

The template includes a GitHub Actions workflow (.github/workflows/ci.yml):

  • Unit tests: Fast feedback on basic functionality
  • Integration tests: Full MCP protocol validation
  • Coverage reporting: Ensure code quality
  • Build validation: Verify compilation

Environment Variables

Production deployment requires:

BITSO_API_KEY=your-production-api-key
BITSO_API_SECRET=your-production-api-secret
BITSO_API_ENDPOINT=https://api.bitso.com  # Production endpoint
CACHE_TTL_SECONDS=300
TIMEOUT=30000

Best Practices

Tool Development

  1. Always use Zod schemas for parameter validation
  2. Return MCP-compliant responses with { content: [...] } format
  3. Handle errors gracefully with user-friendly messages
  4. Log extensively for debugging and monitoring
  5. Test through MCP protocol using integration tests

Error Handling

// Good: MCP-compliant error response
return {
  content: [
    {
      type: "text",
      text: `Error: ${error.message}`
    }
  ]
};

// Bad: Throwing unhandled errors
throw new Error("Something went wrong");

Performance

  • Use caching for expensive API calls
  • Implement request timeouts
  • Log performance metrics
  • Monitor API rate limits

Troubleshooting

Common Issues

Tool not appearing in Claude:

  1. Check build succeeded: npm run build
  2. Restart Claude Desktop
  3. Check mcp-debug.log for errors
  4. Verify claude_desktop_config.json configuration

Tests failing:

  1. Run unit tests first: npm run test:unit
  2. Check MSW handlers match your API expectations
  3. Verify integration tests use real MCP server instances

API connection issues:

  1. Verify environment variables are set
  2. Test API credentials manually
  3. Check network connectivity and firewalls
  4. Review API endpoint URLs

Debug Mode

Enable detailed logging:

DEBUG=true npm start

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass: npm test
  5. Build successfully: npm run build
  6. Submit a pull request

License

MIT License. See LICENSE for details.

Related Resources

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选