MCP Test Server

MCP Test Server

A comprehensive testing server for validating MCP scanner tools and implementations, providing diverse tools, resources, and prompts that exercise various aspects of the Model Context Protocol specification.

Category
访问服务器

README

MCP Test Server

A comprehensive Model Context Protocol (MCP) server designed specifically for testing MCP scanners and validating MCP implementations. This server provides a rich set of tools, resources, and prompts to exercise various aspects of the MCP specification.

🔍 Scanner Compatible: This repository is fully configured to be detected by the APIsec MCP Audit Scanner.

⚡ Quick Start: Want to test scanner detection immediately? See QUICK_START.md

Scanner Detection Documentation

Features

🛠️ Tools

The server exposes multiple tools with varying complexity levels:

  • echo - Basic string echo for testing simple parameter handling
  • add_numbers - Numeric operations testing
  • format_json - JSON object handling and formatting
  • list_operations - Array/list manipulation (sort, reverse, count, join)
  • complex_schema - Nested object schemas with various types
  • timestamp - Tools with optional parameters only

📦 Resources

Multiple resource types for testing resource discovery and reading:

  • static-text - Plain text resource
  • json-data - Structured JSON data
  • markdown-doc - Formatted markdown documentation
  • config - Configuration file example

💬 Prompts

Sample prompts to test prompt capabilities:

  • test-prompt - Basic prompt with required argument
  • debug-prompt - Multi-argument prompt with optional parameters

Installation

From Source

# Clone the repository
git clone <repository-url>
cd mcp-test

# Install the package
pip install .

Development Installation

# Install with development dependencies
pip install -e ".[dev]"

Usage

Running the Server

Command Line

After installation, run the server directly:

mcp-test-server

Python Module

Alternatively, run as a Python module:

python server.py

Testing with MCP Client

The server uses stdio transport, so you can test it with any MCP-compatible client:

import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def test_mcp_server():
    server_params = StdioServerParameters(
        command="mcp-test-server",
        args=[],
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            
            # List available tools
            tools = await session.list_tools()
            print(f"Available tools: {[t.name for t in tools.tools]}")
            
            # Call a tool
            result = await session.call_tool("echo", {"message": "Hello MCP!"})
            print(f"Result: {result}")

if __name__ == "__main__":
    asyncio.run(test_mcp_server())

Configuration for MCP Clients

Add to your MCP client configuration (e.g., Claude Desktop config):

{
  "mcpServers": {
    "mcp-test": {
      "command": "mcp-test-server"
    }
  }
}

Or with explicit Python path:

{
  "mcpServers": {
    "mcp-test": {
      "command": "python",
      "args": ["-m", "server"]
    }
  }
}

Testing MCP Scanners

This server is ideal for testing MCP scanner tools because it provides:

  1. Diverse Tool Schemas - From simple strings to complex nested objects
  2. Multiple Resource Types - Different MIME types and content structures
  3. Edge Cases - Tools with no required parameters, optional fields, enums
  4. Standard Compliance - Follows MCP specification strictly
  5. Scanner Detection - Multiple configuration files for detection testing

Scanner Detection

This repository is configured to be detected by MCP scanner tools like the APIsec MCP Audit Scanner.

Detection files included:

  • mcp.json - Claude Desktop style configuration
  • mcp.yaml - YAML format configuration
  • .mcp/config.json - Hidden directory config
  • package.json - npm dependencies with @modelcontextprotocol/sdk
  • requirements.txt - Python dependencies with modelcontextprotocol

📖 See SCANNER_GUIDE.md for detailed scanner testing instructions.

Scanner Test Checklist

  • [ ] Discovers all 6 tools
  • [ ] Parses complex nested schemas correctly
  • [ ] Identifies all 4 resources with correct URIs
  • [ ] Handles tools with optional-only parameters
  • [ ] Recognizes prompt capabilities
  • [ ] Correctly interprets enum constraints
  • [ ] Handles array and object types

Project Structure

mcp-test/
├── server.py              # Main MCP server implementation
├── pyproject.toml         # Package configuration
├── package.json           # npm metadata (for scanner detection)
├── requirements.txt       # Python dependencies
├── README.md             # This file
├── SCANNER_GUIDE.md      # Scanner detection guide
├── .gitignore            # Git ignore rules
├── LICENSE               # MIT License
├── mcp.json              # MCP configuration (Claude Desktop style)
├── mcp.yaml              # MCP configuration (YAML format)
├── mcp-config.json       # Example client configuration
├── .mcp/                 # MCP metadata directory
│   ├── config.json       # Scanner-detectable config
│   └── mcp.json          # MCP metadata
├── examples/             # Example usage scripts
│   ├── README.md
│   ├── test_client.py
│   └── scanner_test.py
└── tests/                # Unit tests
    ├── __init__.py
    └── test_server.py

Requirements

  • Python 3.10 or higher
  • mcp >= 0.9.0

Development

Running Tests

pytest tests/

Code Style

This project follows PEP 8 guidelines. Format code with:

black server.py

API Reference

Tools

echo

  • Input: message (string, required)
  • Output: Echoes the input message
  • Purpose: Test basic string parameter handling

add_numbers

  • Input: a (number), b (number)
  • Output: Sum of the two numbers
  • Purpose: Test numeric parameter handling

format_json

  • Input: data (object), indent (number, default: 2)
  • Output: Formatted JSON string
  • Purpose: Test object parameter handling

list_operations

  • Input: items (array), operation (enum), separator (string, optional)
  • Output: Result of list operation
  • Purpose: Test array handling and enum constraints

complex_schema

  • Input: Nested object with user info and options
  • Output: Processed data structure
  • Purpose: Test complex nested schema parsing

timestamp

  • Input: format (enum, optional)
  • Output: Current timestamp in specified format
  • Purpose: Test tools with all-optional parameters

Resources

All resources use URIs in the format mcp://test/{resource-name}:

  • mcp://test/static-text - Plain text content
  • mcp://test/json-data - Structured JSON
  • mcp://test/markdown-doc - Markdown documentation
  • mcp://test/config - Configuration data

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues, questions, or contributions, please open an issue on the repository.

Changelog

v0.1.0 (Initial Release)

  • Basic MCP server implementation
  • 6 diverse tools for testing
  • 4 resource types
  • 2 sample prompts
  • Complete documentation

Related Projects


Note: This is a testing server. Do not use in production environments.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选