esapi-mcp-server

Msouther-RT/esapi-mcp-server

3.2

If you are the rightful owner of esapi-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The ESAPI MCP Server is a Model Context Protocol server that provides AI language models with accurate ESAPI documentation and code templates, eliminating API hallucination issues.

Tools
  1. search_api_examples

    Search through 8,154+ ESAPI examples using natural language.

  2. get_esapi_template

    Get code templates for different ESAPI script types.

  3. check_model_status

    Check if the embedding model has finished loading.

ESAPI MCP Server

A Model Context Protocol (MCP) server that provides AI language models with accurate ESAPI (Eclipse Scripting API) documentation and code templates, eliminating API hallucination issues.

šŸ–„ļø Claude Desktop Setup

This server is designed to work with Claude Desktop using the Model Context Protocol (MCP). Follow these steps to connect:

Prerequisites

Configuration Steps

  1. Download and Install Claude Desktop

  2. Locate Claude Desktop Config File

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  3. Add ESAPI MCP Server Configuration

    Edit the config file and add the following (adjust paths to your setup):

    Windows Example:

    {
      "mcpServers": {
        "esapi_mcp": {
          "command": "C:\\path\\to\\your\\project\\esapi-mcp-server\\.venv\\Scripts\\python.exe",
          "args": ["C:\\path\\to\\your\\project\\esapi-mcp-server\\src\\mcp_server.py"],
          "cwd": "C:\\path\\to\\your\\project\\esapi-mcp-server",
          "env": {},
          "timeout": 120000
        }
      }
    }
    

    macOS/Linux Example:

    {
      "mcpServers": {
        "esapi_mcp": {
          "command": "/path/to/your/project/esapi-mcp-server/.venv/bin/python",
          "args": ["/path/to/your/project/esapi-mcp-server/src/mcp_server.py"],
          "cwd": "/path/to/your/project/esapi-mcp-server",
          "env": {},
          "timeout": 120000
        }
      }
    }
    
  4. Restart Claude Desktop

    • Close Claude Desktop completely
    • Reopen Claude Desktop
    • The ESAPI MCP tools should now be available

Troubleshooting

  • Tools not appearing: Check that file paths in config are correct and use forward slashes or escaped backslashes
  • Server not starting: Ensure the virtual environment is properly set up with uv sync
  • Permission errors: Make sure Claude Desktop has permission to execute Python in your project directory
  • Timeout errors: Increase the timeout value if the embedding model takes longer to load

Learn More

For detailed MCP setup instructions, see: Model Context Protocol Documentation

šŸš€ Features

  • šŸ” Semantic API Search: Find relevant ESAPI examples using natural language queries
  • šŸ“ Code Templates: Get correct boilerplate for different ESAPI script types
  • ⚔ Fast Lookup: Pre-computed embeddings for instant search results (8,154+ examples)
  • šŸŽÆ Accurate Results: Based on real ESAPI documentation, not AI guesses
  • 🧠 Smart Matching: Uses Qwen3 embedding model for semantic understanding

šŸ“‹ Quick Start

Prerequisites

  • Python 3.11+
  • UV (recommended) or pip

Installation

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/esapi-mcp-server
    cd esapi-mcp-server
    
    
  2. Setup environment with UV bashuv sync .venv\Scripts\activate # Windows source .venv/bin/activate # Linux/Mac

  3. Run the server bashpython src\mcp_server.py

  4. Connect to your AI client

Add as MCP server in Claude Desktop or compatible AI client Server runs on stdio transport

šŸ› ļø Available Tools

search_api_examples(query: str)

Search through 8,154+ ESAPI examples using natural language:

# Example queries:
search_api_examples("how to get DVH data")
search_api_examples("calculate dose statistics")
search_api_examples("access beam parameters")
search_api_examples("patient plan information")

get_esapi_template(script_type: str)

Get code templates for different ESAPI script types:

get_esapi_template("single_file")      # Simple .cs file
get_esapi_template("binary_plugin")    # Plugin with .cs + .csproj
get_esapi_template("executable_script") # Standalone executable
get_esapi_template("list")             # Show all available types

check_model_status()

Check if the embedding model has finished loading.

šŸ“ Project Structure

esapi-mcp-server/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ mcp_server.py           # Main MCP server
│   └── embed_instructions.py   # Embedding generation script
ā”œā”€ā”€ templates/                  # ESAPI code templates
│   ā”œā”€ā”€ single_file.cs
│   ā”œā”€ā”€ binary_plugin.cs
│   ā”œā”€ā”€ binary_plugin.csproj
│   ā”œā”€ā”€ executable_script.cs
│   └── executable_script.csproj
ā”œā”€ā”€ embeddings/                 # Pre-computed embeddings
│   ā”œā”€ā”€ metadata.pkl           # Questions & answers
│   └── instruction_embeddings.pkl  # Vector embeddings
ā”œā”€ā”€ data/                      # Training data
└── pyproject.toml             # Project configuration

šŸ”§ Development

This project uses UV for fast dependency management.

# Install development dependencies
uv sync --dev

# Run the server
uv run python src/mcp_server.py

# Generate new embeddings (if needed)
uv run python src/embed_instructions.py

šŸ“Š Dataset

  • 8,154+ ESAPI examples from comprehensive documentation (16.1 Libraries)
  • Semantic embeddings using Qwen/Qwen3-Embedding-0.6B model
  • Real API calls with accurate parameters and return types
  • Multiple script patterns covering common ESAPI use cases

šŸŽÆ Use Cases

Perfect for medical physicists and developers working with:

  • Treatment planning automation
  • Dose analysis scripts
  • Quality assurance tools
  • Research applications
  • Educational projects

šŸ¤ Contributing

This Repo is new, as a result it will have areas for vast improvement.

I plan to continually improve and enhance this repo when I have time to dedicate to it.

That being said, contributions are welcome, and encouraged! Areas for improvement:

  • Additional ESAPI examples
  • New script templates
  • Documentation improvements
  • Performance optimizations

šŸ“„ License

MIT License - feel free to use in your medical physics workflows.

šŸ™ Acknowledgments

Built for the medical physics community to improve ESAPI development experience and reduce API documentation friction.


Note: This tool provides accurate ESAPI documentation but always validate scripts in a safe testing environment before clinical use.