Transform Knowledge Graph Brain into a standard REST API for seamless integration with Open WebUI, Postman, and any OpenAPI-compatible application.
The OpenAPI integration uses the mcpo (Model Context Protocol to OpenAPI) proxy to automatically convert our Universal MCP Server into a standard REST API with auto-generated OpenAPI documentation.
Open WebUI / Apps → REST/OpenAPI → mcpo Proxy → MCP Protocol → Knowledge Graph MCP Server → Orchestrator
- ✅ Zero Configuration for Apps: Open WebUI automatically discovers all 16 knowledge graph tools
- ✅ Interactive Documentation: Swagger UI at
/docsfor testing and exploration - ✅ Standard REST API: All tools accessible via POST endpoints
- ✅ Type Safety: Auto-generated OpenAPI schema ensures proper validation
- ✅ Production Ready: Handles authentication, CORS, and error handling
- Knowledge Graph Brain orchestrator running
- Python 3.11+ environment
mcpopackage installed
# Create Python virtual environment (if not exists)
python3.13 -m venv .venv
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
# Install mcpo
pip install mcpocd mcp-server
# Build MCP server
npm install && npm run build
# Start mcpo proxy (this starts both the proxy and MCP server)
../.venv/bin/mcpo --port 8080 -- node ./dist/index.js# Check proxy health
curl http://localhost:8080/docs
# Test an endpoint
curl -X POST "http://localhost:8080/list_knowledge_bases" \
-H "Content-Type: application/json" \
-d '{"include_stats": true}'All 16 MCP tools are automatically exposed as POST endpoints:
POST /ask_knowledge_graph- Natural language Q&A with GraphRAGPOST /search_semantic- Vector similarity searchPOST /search_graph- Structured Cypher queriesPOST /explore_relationships- Entity relationship exploration
POST /switch_knowledge_base- Switch context between KBsPOST /list_knowledge_bases- List all available KBsPOST /add_data_source- Connect new data sourcesPOST /start_ingestion- Trigger data ingestionPOST /get_kb_status- Check KB health and statsPOST /update_schema- Configure KB schema
POST /get_overview- Comprehensive KB overviewPOST /explore_schema- Analyze graph structurePOST /find_patterns- Discover data patternsPOST /get_session_info- Session context and history
-
Start the proxy as shown above
-
Configure Open WebUI to use the API:
- Base URL:
http://localhost:8080 - API Type: OpenAPI/REST
- Documentation:
http://localhost:8080/docs
- Base URL:
-
Test integration:
# In Open WebUI chat: "List all available knowledge bases" # Open WebUI will automatically call POST /list_knowledge_bases
- Import OpenAPI spec:
http://localhost:8080/openapi.json - Set base URL:
http://localhost:8080 - Test endpoints: All 16 tools available as POST requests
// Example: JavaScript client
const KnowledgeGraphAPI = {
baseURL: 'http://localhost:8080',
async askQuestion(question, kbId = null) {
const response = await fetch(`${this.baseURL}/ask_knowledge_graph`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
question,
kb_id: kbId,
include_sources: true,
search_depth: 'deep'
})
});
return response.json();
},
async listKnowledgeBases() {
const response = await fetch(`${this.baseURL}/list_knowledge_bases`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ include_stats: true })
});
return response.json();
}
};
// Usage
const kbs = await KnowledgeGraphAPI.listKnowledgeBases();
const answer = await KnowledgeGraphAPI.askQuestion(
"What are the main components of our system?",
"my-project"
);# Start on different port
../.venv/bin/mcpo --port 9090 --host 0.0.0.0 -- node ./dist/index.js
# With custom path prefix
../.venv/bin/mcpo --port 8080 --path-prefix /api/v1 -- node ./dist/index.js# Create mcpo config file
cat > mcpo.config.json << EOF
{
"servers": {
"knowledge-graph": {
"command": ["node", "./dist/index.js"],
"env": {
"ORCHESTRATOR_URL": "http://localhost:3000"
}
}
},
"port": 8080,
"cors": {
"origins": ["http://localhost:3001", "https://my-app.com"]
}
}
EOF
# Start with config
../.venv/bin/mcpo --config mcpo.config.json# With API key authentication
../.venv/bin/mcpo --port 8080 --api-key "your-secure-api-key" -- node ./dist/index.js
# Then use in requests:
curl -X POST "http://localhost:8080/ask_knowledge_graph" \
-H "Authorization: Bearer your-secure-api-key" \
-H "Content-Type: application/json" \
-d '{"question": "What data do we have?"}'# Dockerfile
FROM node:18-alpine
# Install Python and mcpo
RUN apk add --no-cache python3 py3-pip
RUN pip3 install mcpo
WORKDIR /app
COPY mcp-server/package*.json ./
RUN npm ci --only=production
COPY mcp-server/ ./
RUN npm run build
EXPOSE 8080
CMD ["mcpo", "--port", "8080", "--host", "0.0.0.0", "--", "node", "./dist/index.js"]apiVersion: apps/v1
kind: Deployment
metadata:
name: knowledge-graph-openapi
spec:
replicas: 3
selector:
matchLabels:
app: knowledge-graph-openapi
template:
metadata:
labels:
app: knowledge-graph-openapi
spec:
containers:
- name: openapi-proxy
image: knowledge-graph-openapi:latest
ports:
- containerPort: 8080
env:
- name: ORCHESTRATOR_URL
value: "http://orchestrator-service:3000"
---
apiVersion: v1
kind: Service
metadata:
name: knowledge-graph-openapi
spec:
selector:
app: knowledge-graph-openapi
ports:
- port: 80
targetPort: 8080
type: LoadBalancer# /etc/nginx/sites-available/knowledge-graph-api
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# CORS headers
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
}
}# Proxy health
curl http://localhost:8080/health
# Test core functionality
curl -X POST "http://localhost:8080/list_knowledge_bases" \
-H "Content-Type: application/json" -d '{}'# Start with verbose logging
../.venv/bin/mcpo --port 8080 --log-level DEBUG -- node ./dist/index.js
# Or capture logs
../.venv/bin/mcpo --port 8080 -- node ./dist/index.js > mcpo.log 2>&1The mcpo proxy provides basic metrics at /metrics (if enabled):
curl http://localhost:8080/metricsConnection Refused
# Check if orchestrator is running
curl http://localhost:3000/health
# Check if MCP server builds correctly
cd mcp-server && npm run buildSchema Validation Errors
# Verify MCP server starts standalone
cd mcp-server && node dist/index.js
# Should show "Available tools: ..." without errorsCORS Issues
# Start with permissive CORS for testing
../.venv/bin/mcpo --port 8080 --cors-origins "*" -- node ./dist/index.jsAuthentication Problems
# Test without authentication first
../.venv/bin/mcpo --port 8080 -- node ./dist/index.js
# Then add authentication step by step# Enable verbose logging
export MCPO_LOG_LEVEL=DEBUG
../.venv/bin/mcpo --port 8080 -- node ./dist/index.jsAll endpoints accept POST requests with JSON bodies:
{
"parameter1": "value1",
"parameter2": "value2"
}All endpoints return consistent JSON responses:
{
"success": true,
"data": {...},
"message": "Operation completed successfully"
}{
"error": "Error description",
"details": {
"code": "ERROR_CODE",
"suggestion": "How to fix this issue"
}
}If you're currently using the MCP server directly:
// MCP client configuration
{
"command": "node",
"args": ["./mcp-server/dist/index.js"]
}// REST API client
const response = await fetch('http://localhost:8080/ask_knowledge_graph', {
method: 'POST',
body: JSON.stringify({ question: "..." })
});- Universal MCP Server - Core MCP server documentation
- API Reference - Complete API documentation
- Architecture Overview - System design
- Deployment Guide - Production deployment patterns
Found an issue or want to improve the OpenAPI integration?
- Report bugs: Issues with mcpo proxy or OpenAPI generation
- Suggest features: New endpoints or authentication methods
- Contribute examples: Integration patterns for other platforms
- Improve docs: Help make this guide more comprehensive
- mcpo Documentation - Official mcpo proxy documentation
- OpenAPI Specification - OpenAPI standard
- Open WebUI - Open WebUI integration guides