mcp-server-final

Avinash-Venkatswamy/mcp-server-final

3.1

If you are the rightful owner of mcp-server-final 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 MCP Server is a standalone server providing HTTP REST API and WebSocket endpoints for Model Context Protocol operations, facilitating integrations with platforms like Jira and ServiceNow.

MCP Server

A standalone MCP (Model Context Protocol) server that provides HTTP REST API and WebSocket endpoints for MCP operations. This server can be used by any application to interact with MCP servers for Jira, ServiceNow, and other integrations.

Features

  • REST API: HTTP endpoints for MCP server management and operations
  • WebSocket API: Real-time communication for MCP operations
  • Server Management: Start, stop, restart, and monitor MCP servers
  • Tool Execution: Execute MCP tools and process natural language requests
  • Configuration Management: Dynamic configuration updates
  • Health Monitoring: Server health checks and status monitoring

Architecture

mcp-server/
ā”œā”€ā”€ 01_server/           # Core server components
│   ā”œā”€ā”€ 01_core/         # Core MCP functionality
│   ā”œā”€ā”€ 02_api/          # REST and WebSocket APIs
│   ā”œā”€ā”€ 03_config/       # Configuration management
│   └── 04_utils/        # Utility functions
ā”œā”€ā”€ 02_mcp_servers/      # MCP server configurations
│   ā”œā”€ā”€ 01_jira_mcp/     # Jira MCP server
│   ā”œā”€ā”€ 02_servicenow_mcp/ # ServiceNow MCP server
│   └── 03_common/       # Common MCP components
ā”œā”€ā”€ 03_communication/    # Communication libraries
ā”œā”€ā”€ 04_documentation/    # Documentation
ā”œā”€ā”€ 05_tests/           # Test suites
└── 06_deployment/      # Deployment scripts

Quick Start

Prerequisites

  • Python 3.8 or higher
  • Virtual environment (recommended)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd mcp-server
    
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies

    pip install -r requirements.txt
    
  4. Configure environment

    cp env.example .env
    # Edit .env with your configuration
    
  5. Start the server

    python main.py
    

The server will start on http://localhost:8001

API Endpoints

REST API

Server Management
  • GET /api/v1/status - Get overall system status
  • POST /api/v1/servers/start - Start an MCP server
  • POST /api/v1/servers/stop - Stop an MCP server
  • POST /api/v1/servers/restart - Restart an MCP server
MCP Operations
  • GET /api/v1/mcp/tools - Get available tools from an MCP server
  • POST /api/v1/mcp/process_request - Process a natural language request
  • POST /api/v1/mcp/call_tool - Call a specific MCP tool
Configuration
  • GET /api/v1/config - Get current configuration
  • PUT /api/v1/config - Update configuration
  • POST /api/v1/config/reload - Reload configuration

WebSocket API

Connect to ws://localhost:8001/ws for real-time communication.

Message Types
  • ping - Health check
  • subscribe - Subscribe to events
  • mcp_request - MCP operation request
  • server_action - Server management action
Events
  • mcp_server_status - Server status updates
  • mcp_tool_execution - Tool execution results
  • mcp_error - Error notifications
  • server_health_update - Health updates

Usage Examples

REST API Examples

Start a Jira MCP Server
curl -X POST "http://localhost:8001/api/v1/servers/start" \
  -H "Content-Type: application/json" \
  -d '{"server_name": "jira-mcp", "action": "start"}'
Process a Natural Language Request
curl -X POST "http://localhost:8001/api/v1/mcp/process_request" \
  -H "Content-Type: application/json" \
  -d '{
    "request": "Get all active users from Jira",
    "system": "jira",
    "provider": "openai",
    "api_key": "your_api_key"
  }'
Get Available Tools
curl "http://localhost:8001/api/v1/mcp/tools?server_name=jira-mcp"

WebSocket Examples

JavaScript Client
const ws = new WebSocket('ws://localhost:8001/ws');

ws.onopen = function() {
    // Subscribe to events
    ws.send(JSON.stringify({
        type: 'subscribe',
        events: ['mcp_server_status', 'mcp_tool_execution']
    }));
    
    // Send MCP request
    ws.send(JSON.stringify({
        type: 'mcp_request',
        request_id: '123',
        request: 'Get active users from Jira',
        system: 'jira'
    }));
};

ws.onmessage = function(event) {
    const data = JSON.parse(event.data);
    console.log('Received:', data);
};
Python Client
import websockets
import json
import asyncio

async def mcp_client():
    uri = "ws://localhost:8001/ws"
    async with websockets.connect(uri) as websocket:
        # Subscribe to events
        await websocket.send(json.dumps({
            "type": "subscribe",
            "events": ["mcp_server_status", "mcp_tool_execution"]
        }))
        
        # Send MCP request
        await websocket.send(json.dumps({
            "type": "mcp_request",
            "request_id": "123",
            "request": "Get active users from Jira",
            "system": "jira"
        }))
        
        # Listen for responses
        async for message in websocket:
            data = json.loads(message)
            print(f"Received: {data}")

asyncio.run(mcp_client())

Configuration

Environment Variables

VariableDescriptionDefault
MCP_SERVER_PORTServer port8001
MCP_SERVER_HOSTServer host0.0.0.0
MCP_LOG_LEVELLogging levelINFO
MCP_MAX_CONNECTIONSMax WebSocket connections100
MCP_AUTH_TOKENAuthentication token-
OPENAI_API_KEYOpenAI API key-
ANTHROPIC_API_KEYAnthropic API key-

MCP Server Configuration

MCP servers are configured in the 02_mcp_servers/ directory:

  • 01_jira_mcp/01_config.json - Jira MCP server configuration
  • 02_servicenow_mcp/01_config.json - ServiceNow MCP server configuration

Development

Running Tests

# Run all tests
python -m pytest 05_tests/

# Run specific test categories
python -m pytest 05_tests/01_unit_tests/
python -m pytest 05_tests/02_integration_tests/
python -m pytest 05_tests/03_api_tests/

Code Structure

  • Core Components: MCP server management, launcher, client integration
  • API Layer: REST and WebSocket endpoints
  • Configuration: Environment and server configuration management
  • Utilities: Health checks, process management, security

Deployment

Docker Deployment

# Build image
docker build -t mcp-server .

# Run container
docker run -p 8001:8001 mcp-server

Production Deployment

  1. Set up environment variables
  2. Configure reverse proxy (nginx)
  3. Set up SSL certificates
  4. Configure monitoring and logging
  5. Set up process management (systemd, supervisor)

Troubleshooting

Common Issues

  1. Port already in use

    • Check if another service is using port 8001
    • Change port in configuration
  2. MCP server not starting

    • Check MCP server configuration
    • Verify dependencies are installed
    • Check logs for errors
  3. WebSocket connection issues

    • Verify WebSocket endpoint is accessible
    • Check firewall settings
    • Ensure proper message format

Logs

Logs are written to mcp_server.log by default. Set LOG_LEVEL in environment for more detailed logging.

Contributing

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

License

[Add your license information here]

Support

For support and questions:

  • Create an issue in the repository
  • Check the documentation
  • Review the troubleshooting section