🌐 Enhanced HTTP API
Access all Nexus MCP Server tools from any programming language using our comprehensive REST API. No MCP protocol knowledge required!
🌟 Overview
The Enhanced HTTP API transforms Nexus from a Python/MCP-specific tool into a universal, language-agnostic service that can be integrated into any technology stack.
🔄Dynamic Tool Discovery
- Automatic detection of all tools
- Zero configuration required
- Hot reload support
- Metadata extraction
🌐Language-Agnostic Access
- Standard HTTP/JSON interface
- Any programming language
- Simple integration
- No MCP dependency
📚Comprehensive Documentation
- OpenAPI/Swagger docs
- Interactive testing
- Tool metadata
- Error handling details
📊Production Ready
- Prometheus monitoring
- Health checks
- Error tracking
- Performance metrics
⚡ Quick Start
1. Start the HTTP Server
# Start the enhanced HTTP API server
python http_server.py
# Server starts on http://localhost:9999
# API documentation available at http://localhost:9999/docs
2. Test the API
🌐 Browser Testing
Visit the interactive documentation:
- Swagger UI:
http://localhost:9999/docs - ReDoc:
http://localhost:9999/redoc
⚡ Quick Test
# Health check
curl http://localhost:9999/
# List tools
curl http://localhost:9999/tools
# Execute a tool
curl -X POST http://localhost:9999/execute \
-H "Content-Type: application/json" \
-d '{"tool_name": "add", "arguments": {"a": 5, "b": 3}}'
📋 API Endpoints
Health & Discovery
GET / - Health Check
Basic health check endpoint
{
"status": "healthy",
"message": "Nexus MCP Server Enhanced API is running",
"tools_count": 39,
"server_info": {
"name": "NexusServer-Enhanced",
"version": "0.9.1",
"type": "HTTP-MCP Bridge"
}
}
GET /tools - List All Tools
Get complete list of available tools with metadata
{
"tools": [
{
"name": "add",
"description": "Calculate the sum of two numbers (a + b)",
"input_schema": {
"type": "object",
"properties": {
"a": {"type": "number", "description": "First number"},
"b": {"type": "number", "description": "Second number"}
},
"required": ["a", "b"]
}
}
],
"count": 39,
"server_info": {...}
}
GET /tools/{tool_name} - Tool Details
Get detailed information about a specific tool
{
"name": "add",
"description": "Calculate the sum of two numbers (a + b)",
"input_schema": {
"type": "object",
"properties": {
"a": {"type": "number"},
"b": {"type": "number"}
},
"required": ["a", "b"]
}
}
Tool Execution
POST /execute - Execute Tool
Execute any available tool with parameters
Request:
{
"tool_name": "add",
"arguments": {
"a": 10,
"b": 5
}
}
Response:
{
"success": true,
"result": {
"sum": 15,
"operation": "10 + 5",
"message": "Addition completed successfully"
},
"execution_time": 0.001,
"tool_name": "add"
}
POST /tools/{tool_name}/execute - Direct Tool Execution
Execute specific tool directly via URL path
curl -X POST http://localhost:9999/tools/add/execute \
-H "Content-Type: application/json" \
-d '{"a": 15, "b": 27}'
Monitoring & Metrics
GET /health - Detailed Health Check
Comprehensive health status with system information
{
"status": "healthy",
"timestamp": "2024-01-15T10:30:45Z",
"uptime": 3600,
"system": {
"cpu_percent": 5.2,
"memory_percent": 15.8,
"disk_percent": 45.3
},
"tools": {
"total": 39,
"enabled": 39,
"failed": 0
}
}
GET /metrics - Prometheus Metrics
Prometheus-compatible metrics for monitoring
# HELP mcp_tool_executions_total Total number of tool executions
# TYPE mcp_tool_executions_total counter
mcp_tool_executions_total{tool_name="add",status="success"} 42
# HELP mcp_tool_execution_duration_seconds Tool execution duration
# TYPE mcp_tool_execution_duration_seconds histogram
mcp_tool_execution_duration_seconds_bucket{tool_name="add",le="0.1"} 38
💻 Language Examples
🐍 Python
Using requests library
import requests
# API base URL
BASE_URL = "http://localhost:9999"
def call_nexus_tool(tool_name, arguments):
"""Execute a Nexus tool via HTTP API"""
response = requests.post(
f"{BASE_URL}/execute",
json={
"tool_name": tool_name,
"arguments": arguments
}
)
return response.json()
# Example usage
result = call_nexus_tool("add", {"a": 10, "b": 5})
print(f"Result: {result['result']['sum']}")
# Generate secure password
password_result = call_nexus_tool("password_generate", {
"length": 16,
"include_symbols": True
})
print(f"Password: {password_result['result']['password']}")
# Get system information
system_info = call_nexus_tool("system_overview", {})
print(f"OS: {system_info['result']['os']}")
🌐 JavaScript/Node.js
Using fetch API
class NexusClient {
constructor(baseUrl = 'http://localhost:9999') {
this.baseUrl = baseUrl;
}
async executeTool(toolName, arguments) {
const response = await fetch(`${this.baseUrl}/execute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
tool_name: toolName,
arguments: arguments
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
}
async listTools() {
const response = await fetch(`${this.baseUrl}/tools`);
return await response.json();
}
}
// Example usage
const nexus = new NexusClient();
// Execute mathematical calculation
nexus.executetool('add', { a: 15, b: 27 })
.then(result => {
console.log(`Sum: ${result.result.sum}`);
});
// Generate UUID
nexus.executeTools('generate_uuid', { version: 4 })
.then(result => {
console.log(`UUID: ${result.result.uuid}`);
});
🔷 Go
Using net/http
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
type NexusClient struct {
BaseURL string
Client *http.Client
}
type ExecuteRequest struct {
ToolName string `json:"tool_name"`
Arguments map[string]interface{} `json:"arguments"`
}
type ExecuteResponse struct {
Success bool `json:"success"`
Result map[string]interface{} `json:"result"`
ExecutionTime float64 `json:"execution_time"`
ToolName string `json:"tool_name"`
}
func NewNexusClient(baseURL string) *NexusClient {
return &NexusClient{
BaseURL: baseURL,
Client: &http.Client{},
}
}
func (c *NexusClient) ExecuteTool(toolName string, arguments map[string]interface{}) (*ExecuteResponse, error) {
reqBody := ExecuteRequest{
ToolName: toolName,
Arguments: arguments,
}
jsonData, err := json.Marshal(reqBody)
if err != nil {
return nil, err
}
resp, err := c.Client.Post(
c.BaseURL+"/execute",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var result ExecuteResponse
err = json.Unmarshal(body, &result)
return &result, err
}
func main() {
client := NewNexusClient("http://localhost:9999")
// Execute addition
result, err := client.ExecuteTool("add", map[string]interface{}{
"a": 10,
"b": 5,
})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Sum: %.0f\n", result.Result["sum"])
}
🦀 Rust
Using reqwest and serde
use reqwest;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize)]
struct ExecuteRequest {
tool_name: String,
arguments: HashMap,
}
#[derive(Deserialize)]
struct ExecuteResponse {
success: bool,
result: HashMap,
execution_time: f64,
tool_name: String,
}
struct NexusClient {
base_url: String,
client: reqwest::Client,
}
impl NexusClient {
fn new(base_url: String) -> Self {
NexusClient {
base_url,
client: reqwest::Client::new(),
}
}
async fn execute_tool(&self, tool_name: &str, arguments: HashMap) -> Result> {
let request = ExecuteRequest {
tool_name: tool_name.to_string(),
arguments,
};
let response = self.client
.post(&format!("{}/execute", self.base_url))
.json(&request)
.send()
.await?;
let result: ExecuteResponse = response.json().await?;
Ok(result)
}
}
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = NexusClient::new("http://localhost:9999".to_string());
let mut args = HashMap::new();
args.insert("a".to_string(), serde_json::Value::Number(serde_json::Number::from(10)));
args.insert("b".to_string(), serde_json::Value::Number(serde_json::Number::from(5)));
let result = client.execute_tool("add", args).await?;
println!("Sum: {}", result.result.get("sum").unwrap());
Ok(())
}
🚨 Error Handling
Error Response Format
Standard Error Response
{
"success": false,
"error": {
"code": "TOOL_NOT_FOUND",
"message": "Tool 'invalid_tool' not found",
"details": {
"available_tools": ["add", "subtract", "multiply", "divide"],
"suggestion": "Did you mean 'add'?"
}
},
"timestamp": "2024-01-15T10:30:45Z"
}
Common Error Codes
| Code | HTTP Status | Description |
|---|---|---|
TOOL_NOT_FOUND |
404 | Requested tool does not exist |
INVALID_ARGUMENTS |
400 | Tool arguments are invalid or missing |
EXECUTION_ERROR |
500 | Tool execution failed |
TIMEOUT |
408 | Tool execution timed out |
RATE_LIMIT |
429 | Too many requests |
⚙️ Configuration
Server Configuration
# Start server with custom configuration
python http_server.py \
--host 0.0.0.0 \
--port 8080 \
--workers 4 \
--timeout 300
Environment Variables
| Variable | Default | Description |
|---|---|---|
NEXUS_API_HOST |
localhost |
API server host |
NEXUS_API_PORT |
9999 |
API server port |
NEXUS_API_WORKERS |
1 |
Number of worker processes |
NEXUS_API_TIMEOUT |
60 |
Request timeout in seconds |
NEXUS_ENABLE_CORS |
true |
Enable CORS headers |
✨ Benefits
🔧No Tool Modifications
Enhancement is implemented upstream - no changes to individual tool files required
🌍Language Independence
Use Nexus from any programming language that supports HTTP requests
📈Automatic Scaling
New tools are immediately API-accessible without additional configuration
🚀Production Ready
Comprehensive error handling, monitoring, and performance tracking
📋Standards Compliant
OpenAPI documentation and REST principles for easy integration
👨💻Developer Friendly
Interactive documentation, examples, and comprehensive error messages