thepratyushranjan/MCP-Server
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.
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
-
Install UV package manager
For macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | shFor Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" -
Clone the repository (if applicable):
git clone https://github.com/thepratyushranjan/MCP-Server.git cd MCP -
Install dependencies using UV (recommended):
uv syncOr using pip:
pip install -r req.txt -
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
-
Start the MCP server:
uv run main.py -
Verify server is running:
uv run client.py
Using with Cursor IDE
- Ensure the MCP configuration is set up in
~/.cursor/mcp.json - Restart Cursor completely
- Open a new chat/conversation
- 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:
- Main Thread: Handles stdio transport for MCP communication
- Background Thread: Runs SSE server for HTTP-based communication
- Tool Implementation: Provides the
query_cloudtunertool
Code Structure
main.py: Core MCP server with tool definitions and transport setupclient.py: Test client for manual MCP server testingtest_cursor_integration.py: Comprehensive integration test suitetests/test_query_cloudtuner.py: Unit tests for API functionality
Troubleshooting
Common Issues
-
Server won't start:
- Check Python version (requires 3.12+)
- Verify all dependencies are installed
- Check if port 8000 is available
-
Cursor integration not working:
- Verify
~/.cursor/mcp.jsonconfiguration - Restart Cursor completely
- Run the integration test to verify setup
- Verify
-
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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- 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