This document describes the MCP (Model Context Protocol) server dashboard and JavaScript SDK implementation for IPFS Datasets Python.
The MCP Dashboard provides a web-based interface for:
- Monitoring MCP server status
- Discovering and executing available tools
- Viewing execution history and results
- Real-time server monitoring
The JavaScript SDK enables web applications to interact with the MCP server programmatically.
ipfs_datasets_py/
├── mcp_dashboard.py # Main dashboard implementation
├── static/admin/
│ ├── js/mcp-sdk.js # JavaScript SDK
│ └── css/mcp-dashboard.css # Dashboard styles
├── templates/admin/
│ └── mcp_dashboard.html # Dashboard template (auto-generated)
└── mcp_server/ # Existing MCP server implementation
├── tools/ # Available MCP tools
└── simple_server.py # MCP server
- Tool Discovery: Automatically discovers available MCP tools by category
- Server Status: Real-time monitoring of MCP server health and statistics
- Tool Execution: Web interface for executing tools with parameters
- Execution History: View and track all tool executions
- REST API: Full REST API for programmatic access
- Simple API: Easy-to-use client for MCP server communication
- Error Handling: Built-in retry logic and error management
- Async Support: Promise-based API with async/await support
- Event System: Event listeners for monitoring operations
- Fluent API: Builder pattern for complex tool executions
- Caching: Intelligent caching of tool discovery results
from ipfs_datasets_py.dashboards.mcp_dashboard import start_mcp_dashboard, MCPDashboardConfig
# Basic configuration
config = MCPDashboardConfig(
host="localhost",
port=8080,
enable_tool_execution=True
)
# Start dashboard
dashboard = start_mcp_dashboard(config)
# Dashboard available at: http://localhost:8080/mcp// Initialize client
const client = new MCPClient('http://localhost:8080/api/mcp');
// Get server status
const status = await client.getServerStatus();
console.log('Server status:', status);
// Discover tools
const tools = await client.getTools();
console.log('Available tools:', tools);
// Execute a tool
const result = await client.executeTool('dataset_tools', 'load_dataset', {
dataset_name: 'my_dataset',
format: 'parquet'
});
console.log('Execution result:', result);| Method | Endpoint | Description |
|---|---|---|
| GET | /api/mcp/status |
Get MCP server status |
| GET | /api/mcp/tools |
List all available tools |
| GET | /api/mcp/tools/{category}/{tool} |
Get tool information |
| POST | /api/mcp/tools/{category}/{tool}/execute |
Execute a tool |
| GET | /api/mcp/executions/{id} |
Get execution status |
| GET | /api/mcp/history |
Get execution history |
| GET | /static/js/mcp-sdk.js |
JavaScript SDK |
config = MCPDashboardConfig(
host="0.0.0.0", # Host to bind to
port=8080, # Port to listen on
mcp_server_host="localhost", # MCP server host
mcp_server_port=8001, # MCP server port
enable_tool_execution=True, # Allow tool execution
tool_timeout=30.0, # Tool execution timeout
max_concurrent_tools=5, # Max concurrent executions
data_dir="/tmp/mcp_dashboard" # Data storage directory
)const client = new MCPClient('http://localhost:8080/api/mcp', {
timeout: 30000, // Request timeout (30s)
retries: 3, // Number of retries
retryDelay: 1000 // Delay between retries
});const result = await client
.tool('analysis_tools', 'analyze_data')
.withParams({
data: 'sample data',
analysis_type: 'statistical'
})
.withOptions({
timeout: 60000
})
.execute();const toolSpecs = [
{ category: 'dataset_tools', toolName: 'load_dataset', parameters: { name: 'dataset1' }},
{ category: 'dataset_tools', toolName: 'load_dataset', parameters: { name: 'dataset2' }},
];
const results = await client.batchExecuteTools(toolSpecs, {
maxConcurrent: 2,
failFast: false
});// Listen for tool execution events
client.on('toolExecutionStart', (data) => {
console.log('Tool execution started:', data);
});
client.on('toolExecutionComplete', (data) => {
console.log('Tool execution completed:', data);
});
// Start status polling
const stopPolling = client.startStatusPolling(5000, (error, status) => {
if (error) {
console.error('Status error:', error);
} else {
console.log('Server status:', status);
}
});The dashboard automatically discovers tools in the following categories:
- dataset_tools: Dataset loading, saving, and manipulation
- embedding_tools: Text and data embedding generation
- vector_tools: Vector operations and similarity search
- analysis_tools: Data analysis and statistics
- workflow_tools: Workflow orchestration and automation
- monitoring_tools: System monitoring and metrics
- admin_tools: Administrative operations
- security_tools: Security and authentication
- audit_tools: Audit logging and compliance
- And many more...
The dashboard provides comprehensive error handling:
try:
dashboard = start_mcp_dashboard(config)
except Exception as e:
print(f"Failed to start dashboard: {e}")The SDK includes custom error types:
try {
const result = await client.executeTool('invalid_category', 'invalid_tool');
} catch (error) {
if (error instanceof MCPError) {
console.error('MCP Error:', error.message);
console.error('Status:', error.status);
console.error('Data:', error.data);
} else {
console.error('Network Error:', error.message);
}
}- Authentication: The dashboard can be configured with authentication
- CORS: Configure CORS settings for production deployments
- Input Validation: All tool parameters are validated before execution
- Rate Limiting: Built-in rate limiting prevents abuse
- Error Sanitization: Errors are sanitized to prevent information leakage
import React, { useState, useEffect } from 'react';
function MCPDashboard() {
const [client] = useState(() => new MCPClient('/api/mcp'));
const [status, setStatus] = useState(null);
const [tools, setTools] = useState({});
useEffect(() => {
const loadData = async () => {
try {
const [statusData, toolsData] = await Promise.all([
client.getServerStatus(),
client.getTools()
]);
setStatus(statusData);
setTools(toolsData);
} catch (error) {
console.error('Failed to load dashboard data:', error);
}
};
loadData();
// Start polling for status updates
const stopPolling = client.startStatusPolling(5000, (error, statusData) => {
if (!error) setStatus(statusData);
});
return stopPolling;
}, [client]);
return (
<div>
<h1>MCP Dashboard</h1>
{status && (
<div>Status: {status.status}</div>
)}
{/* Tool display and execution UI */}
</div>
);
}// Use the included jQuery plugin
$('.mcp-tool-button').mcpToolExecutor({
baseUrl: '/api/mcp',
onResult: (result, element) => {
console.log('Tool executed:', result);
element.addClass('success');
},
onError: (error, element) => {
console.error('Tool failed:', error);
element.addClass('error');
}
});Run the test suite:
python test_mcp_dashboard.pyRun the demo:
python demo_mcp_dashboard.py- Dashboard won't start: Check that the port is not already in use
- Tools not discovered: Verify MCP server tools directory exists
- JavaScript SDK 404: Ensure static files are in the correct directory
- Tool execution fails: Check tool parameters and server logs
Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)
config = MCPDashboardConfig(debug=True)
dashboard = start_mcp_dashboard(config)This implementation is part of the IPFS Datasets Python project and follows the same license terms.