MCP-Server

thepratyushranjan/MCP-Server

3.2

If you are the rightful owner of 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 dayong@mcphub.com.

CloudTuner MCP Server integrates AI clients with CloudTuner's chat agent API using the Model Context Protocol.

Tools
1
Resources
0
Prompts
0

CloudTuner MCP Server

A Model Context Protocol (MCP) server that provides integration with CloudTuner AI services, allowing AI clients like Cursor to interact with CloudTuner's chat agent API.

Overview

This project implements an MCP server that bridges AI clients with CloudTuner's API, enabling natural language queries to CloudTuner's chat agent through the MCP protocol. The server supports both stdio and Server-Sent Events (SSE) transport methods.

Project Structure

MCP/
├── main.py                    # Main MCP server implementation
├── client.py                  # Test client for MCP server
├── test_cursor_integration.py # Integration test for Cursor IDE
├── tests/
│   └── test_query_cloudtuner.py # Unit tests for CloudTuner API
├── pyproject.toml            # Project configuration and dependencies
├── req.txt                   # Alternative requirements file
├── uv.lock                   # UV package manager lock file
└── README.md                 # This documentation

Features

  • CloudTuner Integration: Direct integration with CloudTuner's chat agent API
  • Dual Transport Support: Supports both stdio and SSE transport methods
  • Cursor IDE Integration: Configured for seamless integration with Cursor IDE
  • Comprehensive Testing: Includes unit tests and integration tests
  • Error Handling: Robust error handling for API failures and timeouts

Installation

Prerequisites

  • Python 3.12 or higher
  • UV package manager (recommended) or pip

Setup

  1. Install UV package manager

    For macOS/Linux:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

    For Windows:

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    
  2. Clone the repository (if applicable):

    git clone https://github.com/thepratyushranjan/MCP-Server.git
    cd MCP
    
  3. Install dependencies using UV (recommended):

    uv sync
    

    Or using pip:

    pip install -r req.txt
    
  4. Verify installation:

    uv run python test_cursor_integration.py
    

Configuration

Cursor IDE Integration

The project is configured to work with Cursor IDE. The configuration is stored in ~/.cursor/mcp.json:

{
  "mcpServers": {
    "cloudtuner-mcp": {
      "url": "http://localhost:8000/sse"
    }
  }
}

Server Configuration

The MCP server runs on:

  • Stdio transport: Default MCP communication
  • SSE transport: HTTP Server-Sent Events on http://0.0.0.0:8000

Usage

Running the Server

  1. Start the MCP server:

    uv run main.py
    
  2. Verify server is running:

    uv run client.py
    

Using with Cursor IDE

  1. Ensure the MCP configuration is set up in ~/.cursor/mcp.json
  2. Restart Cursor completely
  3. Open a new chat/conversation
  4. The CloudTuner tool will be available for use

Available Tools

The server provides the following tool:

query_cloudtuner(query: str)

Sends a query to the CloudTuner API and returns the response.

Parameters:

  • query (str): The user query string to send to CloudTuner

Returns:

  • JSON response from CloudTuner API or error information

Example usage in Cursor:

Use the CloudTuner tool to query "What is machine learning?"

API Details

CloudTuner API Integration

The server integrates with CloudTuner's chat agent API:

  • Endpoint: https://localhost/chat-agent/simple-query
  • Method: POST
  • Content-Type: application/json
  • Timeout: 30 seconds
  • Payload: {"query": "your query string"}

Error Handling

The server handles various error scenarios:

  • HTTP Errors: Network issues, API failures
  • Timeout Errors: Requests taking longer than 30 seconds
  • JSON Parsing Errors: Invalid responses from the API

Testing

Unit Tests

Run the unit tests:

uv run python -m unittest tests.test_query_cloudtuner

Integration Tests

Test the complete MCP server integration:

uv run python test_cursor_integration.py

Manual Testing

Test the MCP server manually:

uv run python client.py

Development

Project Dependencies

The project uses the following key dependencies:

  • fastmcp[cli]: MCP framework for Python
  • httpx: HTTP client library for API requests
  • mcp[cli]: Core MCP protocol implementation

Architecture

The server uses a multi-threaded architecture:

  1. Main Thread: Handles stdio transport for MCP communication
  2. Background Thread: Runs SSE server for HTTP-based communication
  3. Tool Implementation: Provides the query_cloudtuner tool

Code Structure

  • main.py: Core MCP server with tool definitions and transport setup
  • client.py: Test client for manual MCP server testing
  • test_cursor_integration.py: Comprehensive integration test suite
  • tests/test_query_cloudtuner.py: Unit tests for API functionality

Troubleshooting

Common Issues

  1. Server won't start:

    • Check Python version (requires 3.12+)
    • Verify all dependencies are installed
    • Check if port 8000 is available
  2. Cursor integration not working:

    • Verify ~/.cursor/mcp.json configuration
    • Restart Cursor completely
    • Run the integration test to verify setup
  3. API errors:

    • Check internet connectivity
    • Verify CloudTuner API endpoint is accessible
    • Check for rate limiting or authentication issues

Debug Mode

For debugging, you can run the server with additional logging:

uv run python main.py

The server will output startup messages and any errors encountered.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

License

[Add license information here]

Support

For issues and questions:

  • Check the troubleshooting section above
  • Run the integration test to diagnose problems
  • Review the logs for error messages

Version History

  • v1.0.0: Initial release with CloudTuner API integration
  • Basic MCP server implementation
  • Cursor IDE integration support
  • Comprehensive testing suite