Application Development Overview
This section helps developers build applications that use the Natural Language Agent.
What You Can Build
The MCP server provides multiple interfaces for building database applications:
- MCP Protocol Clients - Build chat clients that use the JSON-RPC protocol
- Web Applications - Use the LLM proxy and REST APIs
- Custom Integrations - Integrate with existing applications
Quick Start
1. Understanding the Architecture
The MCP server exposes two main interfaces:
- JSON-RPC (MCP Protocol) - For MCP-compatible clients
- REST APIs - For LLM proxy and utility endpoints
See Architecture for the complete system overview.
2. Choose Your Approach
Option A: Build an MCP Protocol Client
Best for: Creating chat clients similar to Claude Desktop
- Implements Model Context Protocol (JSON-RPC 2.0)
- Direct access to MCP tools and resources
- Full control over agentic loop
Option B: Use the LLM Proxy
Best for: Web applications that need AI-powered database access
- Server-side API key management
- Pre-built LLM provider integration
- REST API endpoints
See: LLM Proxy
Option C: Direct API Integration
Best for: Custom integrations and automation
- Direct JSON-RPC access to tools
- No LLM required
- Scriptable and automation-friendly
See: API Reference
Core Concepts
MCP Tools
MCP tools are functions that can be called via the protocol:
query_database- Execute natural language queriesexecute_sql- Run SQL directlyget_schema_info- Get database schemahybrid_search- BM25+MMR semantic searchgenerate_embedding- Create vector embeddings
See: Tools Documentation
MCP Resources
MCP resources provide read-only access to system information:
pg://system_info- PostgreSQL server informationpg://stat/activity- Current database activitypg://stat/database- Database statistics
Authentication
The server supports two authentication modes:
- Token-based - API tokens for automation
- User-based - Username/password for interactive clients
See: Authentication
Example: Building a Simple Client
Here's a minimal example in Python:
import requests
import json
# MCP server endpoint
MCP_URL = "http://localhost:8080/mcp/v1"
SESSION_TOKEN = "your-token-here"
# Initialize connection
response = requests.post(MCP_URL, json={
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "my-client",
"version": "1.0.0"
}
}
}, headers={
"Authorization": f"Bearer {SESSION_TOKEN}"
})
# Call a tool
response = requests.post(MCP_URL, json={
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "query_database",
"arguments": {
"query": "How many tables are in the database?"
}
}
}, headers={
"Authorization": f"Bearer {SESSION_TOKEN}"
})
result = response.json()
print(result)
Development Resources
Documentation
- MCP Protocol Reference - Complete protocol specification
- API Reference - All available endpoints
- LLM Proxy - Building web clients with LLM integration
- Architecture - System design and components
Example Implementations
- Python Examples - Sample chat clients
- Stdio + Anthropic Claude
- HTTP + Ollama
- Go CLI Client - Full-featured reference implementation
- Web Client - React-based web interface
Configuration
- Server Configuration - Configure the MCP server
- Deploying the MCP Server with Docker - Deploy with Docker
- Deploying the MCP Server from Source - Deploy from Source
- Query Examples - Common use cases
Support
- Questions? See Troubleshooting
- Bug reports: GitHub Issues
- Examples: Query Examples