Documentation Index
Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
MCP (Model Context Protocol) Tools enable integration with MCP servers for extended functionality. These tools allow you to connect to both local and remote MCP servers, discover available tools, and execute them with custom inputs using the Python SDK.
Key Features
MCP_LOCAL_RUN
- Connect to local MCP servers
- Execute tools on your local environment
- Direct Python SDK integration
- Real-time tool discovery and execution
MCP_REMOTE_RUN
- Connect to remote MCP servers via HTTP
- Streamable HTTP connections
- Cloud-based tool execution
- Scalable remote processing
Authentication
MCP tools may require authentication depending on the server configuration. Check with your MCP server administrator for specific requirements.
Example: Local MCP Server Integration
- id: connect_local_mcp
name: connect_local_mcp
tool: MCP_LOCAL_RUN
input:
- name: server_config
value: |
{
"server_path": "/path/to/mcp-server",
"server_args": ["--config", "/path/to/config.json"],
"timeout": 30
}
- name: tool_name
value: "file_reader"
- name: tool_inputs
value: |
{
"file_path": "/home/user/documents/report.txt",
"encoding": "utf-8"
}
- id: process_mcp_result
name: process_mcp_result
tool: PYTHON_SANDBOX_RUN
input:
- name: code
value: |
import json
# Process MCP tool result
mcp_result = json.loads('''{{steps.connect_local_mcp.result.output}}''')
print("MCP Tool Execution Results:")
print("=" * 40)
print(f"Tool: {mcp_result.get('tool_name', 'Unknown')}")
print(f"Status: {mcp_result.get('status', 'Unknown')}")
print(f"Execution Time: {mcp_result.get('execution_time', 'N/A')}ms")
print()
if 'data' in mcp_result:
print("Output Data:")
print(mcp_result['data'])
Example: Remote MCP Service Integration
- id: discover_remote_tools
name: discover_remote_tools
tool: MCP_REMOTE_RUN
input:
- name: server_url
value: "https://mcp-server.example.com/api"
- name: auth_token
value: "{{secrets.MCP_AUTH_TOKEN}}"
- name: action
value: "list_tools"
- name: tool_inputs
value: "{}"
- id: execute_remote_analysis
name: execute_remote_analysis
tool: MCP_REMOTE_RUN
input:
- name: server_url
value: "https://mcp-server.example.com/api"
- name: auth_token
value: "{{secrets.MCP_AUTH_TOKEN}}"
- name: tool_name
value: "data_analyzer"
- name: tool_inputs
value: |
{
"data_source": "{{steps.input_data.result.file_url}}",
"analysis_type": "statistical_summary",
"output_format": "json",
"include_charts": true
}
- id: save_analysis_results
name: save_analysis_results
tool: OUTPUT_FILE
input:
- name: content
value: "{{steps.execute_remote_analysis.result.output}}"
- name: filename
value: "mcp_analysis_results_{{date | format('YYYY-MM-DD')}}.json"
- name: fileType
value: "json"
- id: setup_mcp_environment
name: setup_mcp_environment
tool: PYTHON_SANDBOX_RUN
input:
- name: code
value: |
# Define MCP workflow configuration
mcp_workflow = {
"server_config": {
"local_server": "/opt/mcp-tools/server",
"remote_server": "https://api.mcp-cloud.example.com",
"timeout": 60,
"retry_attempts": 3
},
"tools_to_execute": [
{
"name": "document_parser",
"type": "local",
"inputs": {
"document_url": "{{input.document_url}}",
"extract_images": True,
"extract_tables": True
}
},
{
"name": "content_analyzer",
"type": "remote",
"inputs": {
"content_type": "document",
"analysis_depth": "comprehensive"
}
},
{
"name": "report_generator",
"type": "remote",
"inputs": {
"template": "standard_report",
"include_summary": True
}
}
]
}
import json
print(json.dumps(mcp_workflow, indent=2))
- id: parse_document_local
name: parse_document_local
tool: MCP_LOCAL_RUN
input:
- name: server_config
value: |
{
"server_path": "/opt/mcp-tools/server",
"timeout": 60
}
- name: tool_name
value: "document_parser"
- name: tool_inputs
value: |
{
"document_url": "{{input.document_url}}",
"extract_images": true,
"extract_tables": true,
"output_format": "structured_json"
}
- id: analyze_content_remote
name: analyze_content_remote
tool: MCP_REMOTE_RUN
input:
- name: server_url
value: "https://api.mcp-cloud.example.com"
- name: auth_token
value: "{{secrets.MCP_CLOUD_TOKEN}}"
- name: tool_name
value: "content_analyzer"
- name: tool_inputs
value: |
{
"parsed_content": {{steps.parse_document_local.result.output}},
"analysis_type": "comprehensive",
"include_sentiment": true,
"include_entities": true,
"include_summary": true
}
- id: generate_final_report
name: generate_final_report
tool: MCP_REMOTE_RUN
input:
- name: server_url
value: "https://api.mcp-cloud.example.com"
- name: auth_token
value: "{{secrets.MCP_CLOUD_TOKEN}}"
- name: tool_name
value: "report_generator"
- name: tool_inputs
value: |
{
"analysis_results": {{steps.analyze_content_remote.result.output}},
"template": "executive_summary",
"format": "markdown",
"include_charts": true,
"include_recommendations": true
}
- id: save_comprehensive_report
name: save_comprehensive_report
tool: OUTPUT_FILE
input:
- name: content
value: "{{steps.generate_final_report.result.output}}"
- name: filename
value: "comprehensive_analysis_report.md"
- name: fileType
value: "txt"
- id: deploy_custom_mcp_tool
name: deploy_custom_mcp_tool
tool: MCP_LOCAL_RUN
input:
- name: server_config
value: |
{
"server_path": "/usr/local/bin/custom-mcp-server",
"server_args": ["--plugin-dir", "/home/user/mcp-plugins"],
"environment": {
"MCP_DEBUG": "true",
"MCP_LOG_LEVEL": "info"
}
}
- name: tool_name
value: "custom_data_processor"
- name: tool_inputs
value: |
{
"input_data": {{steps.prepare_data.result.processed_data}},
"processing_rules": {
"remove_duplicates": true,
"normalize_dates": true,
"validate_emails": true,
"standardize_phone_numbers": true
},
"output_options": {
"format": "json",
"include_metadata": true,
"include_statistics": true
}
}
- id: validate_mcp_output
name: validate_mcp_output
tool: PYTHON_SANDBOX_RUN
input:
- name: code
value: |
import json
# Validate MCP tool output
try:
mcp_output = json.loads('''{{steps.deploy_custom_mcp_tool.result.output}}''')
print("MCP Tool Validation Results:")
print("=" * 35)
# Check for required fields
required_fields = ['processed_data', 'metadata', 'statistics']
missing_fields = [field for field in required_fields if field not in mcp_output]
if missing_fields:
print(f"❌ Missing required fields: {', '.join(missing_fields)}")
else:
print("✅ All required fields present")
# Validate data structure
if 'processed_data' in mcp_output:
data_count = len(mcp_output['processed_data'])
print(f"📊 Processed {data_count} records")
if 'statistics' in mcp_output:
stats = mcp_output['statistics']
print(f"📈 Processing Statistics:")
for key, value in stats.items():
print(f" {key}: {value}")
print("✅ MCP tool executed successfully")
except json.JSONDecodeError as e:
print(f"❌ Invalid JSON output from MCP tool: {e}")
except Exception as e:
print(f"❌ Error validating MCP output: {e}")
MCP Server Configuration
Local Server Setup
{
"server_path": "/path/to/mcp-server",
"server_args": ["--config", "/path/to/config.json"],
"environment": {
"MCP_LOG_LEVEL": "info",
"MCP_TIMEOUT": "30"
},
"timeout": 60,
"retry_attempts": 3
}
Remote Server Setup
{
"server_url": "https://mcp-server.example.com/api",
"auth_method": "bearer_token",
"auth_token": "your-auth-token",
"timeout": 30,
"stream_response": true
}
- id: discover_tools
name: discover_tools
tool: MCP_LOCAL_RUN
input:
- name: action
value: "list_tools"
- name: server_config
value: '{"server_path": "/path/to/mcp-server"}'
- id: get_tool_info
name: get_tool_info
tool: MCP_REMOTE_RUN
input:
- name: action
value: "describe_tool"
- name: tool_name
value: "data_processor"
- name: server_url
value: "https://mcp-server.example.com/api"
Error Handling
Common Error Types
- Connection errors: Server unreachable or authentication failed
- Tool not found: Specified tool doesn’t exist on server
- Input validation: Invalid inputs for tool execution
- Timeout errors: Tool execution exceeded time limit
- Server errors: Internal server errors during execution
{
"error": {
"type": "tool_execution_error",
"message": "Tool execution failed",
"details": {
"tool_name": "data_processor",
"error_code": "INPUT_VALIDATION_FAILED",
"timestamp": "2024-01-15T14:30:00Z"
}
}
}
Use Cases
- Data Processing: Advanced data transformation and analysis
- Document Processing: Complex document parsing and extraction
- AI/ML Integration: Machine learning model execution
- Custom Workflows: Domain-specific business logic execution
- External API Integration: Wrapper for external services
- Batch Processing: Large-scale data processing operations
- Specialized Tools: Industry-specific processing tools
- Research Tools: Academic and scientific computing tools
Best Practices
- Use local servers for frequent operations
- Use remote servers for compute-intensive tasks
- Implement proper timeout handling
- Cache tool discovery results
Security Considerations
- Secure authentication tokens
- Validate all inputs and outputs
- Use HTTPS for remote connections
- Implement proper error handling
Development Guidelines
- Document custom MCP tools thoroughly
- Implement proper logging and monitoring
- Use consistent input/output schemas
- Test tools thoroughly before deployment