An intelligent Model Context Protocol (MCP) server that provides database analysis and query assistance for DynAPI.
DynAPI MCP Server is a powerful tool that helps you:
- Discover Database Schema: Automatically explore table relationships and structures
- Suggest Optimal JOINs: Intelligently recommend JOIN operations between tables
- Natural Language Queries: Convert plain English to working DynAPI queries
- Performance Analysis: Analyze and optimize query performance
- Generate Examples: Create example queries for any table or scenario
npm install
Copy the example environment file and configure your settings:
cp .env.example .env
# Edit .env with your database and DynAPI settings
npm run build
npm start
Or for development:
npm run dev
Create a .env
file with the following variables:
# Database Connection (same as DynAPI)
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_DATABASE=your_database
DB_SSL=false
# DynAPI Connection
DYNAPI_URL=http://localhost:4000
DYNAPI_API_KEY=your_api_key
# MCP Server Configuration
MCP_SERVER_NAME=dynapi-mcp
MCP_SERVER_VERSION=1.0.0
CACHE_TTL=3600
LOG_LEVEL=info
The server provides 5 powerful tools:
Suggest optimal JOIN operations between database tables.
{
"fromTable": "mapSolarSystems",
"targetTables": ["mapRegions"],
"maxDepth": 2
}
Convert natural language intent into DynAPI query syntax.
{
"intent": "find all trading hubs in high-security space",
"includeExamples": true
}
Explore database schema and relationships.
{
"tableName": "mapSolarSystems",
"includeRelationships": true
}
Analyze query performance and suggest optimizations.
{
"query": "http://localhost:4000/api/query/mapSolarSystems/*?security_gte=0.5",
"includeSuggestions": true
}
Generate example queries for tables/scenarios.
{
"tableName": "mapSolarSystems",
"scenario": "trading hubs",
"includeAdvanced": false
}
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"dynapi-intelligence": {
"command": "node",
"args": ["/path/to/dynapi-mcp/dist/server.js"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_USERNAME": "your_username",
"DB_PASSWORD": "your_password",
"DB_DATABASE": "your_database",
"DYNAPI_URL": "http://localhost:4000",
"DYNAPI_API_KEY": "your-api-key"
}
}
}
}
Cursor IDE supports MCP servers through its built-in configuration system. Here's how to integrate the DynAPI MCP server:
-
Open Cursor Settings
- Press
Ctrl/Cmd + ,
to open settings - Search for "MCP" or navigate to Extensions β MCP
- Press
-
Add MCP Server Configuration
- Click "Add MCP Server" or edit the settings JSON directly
- Copy the configuration from
cursor-mcp-config.json
or add the following configuration:
{
"mcp.servers": {
"dynapi-intelligence": {
"command": "node",
"args": ["/absolute/path/to/dynapi-mcp/dist/server.js"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_USERNAME": "your_username",
"DB_PASSWORD": "your_password",
"DB_DATABASE": "your_database",
"DYNAPI_URL": "http://localhost:4000",
"DYNAPI_API_KEY": "your-api-key",
"LOG_LEVEL": "info"
},
"timeout": 30000,
"initializationOptions": {
"capabilities": {
"tools": true,
"resources": true,
"prompts": true
}
}
}
}
}
For project-specific setup, create a .cursor/mcp.json
file in your workspace root:
{
"servers": {
"dynapi-intelligence": {
"command": "node",
"args": ["./dist/server.js"],
"cwd": "/path/to/dynapi-mcp",
"env": {
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_USERNAME": "your_username",
"DB_PASSWORD": "your_password",
"DB_DATABASE": "your_database",
"DYNAPI_URL": "http://localhost:4000",
"DYNAPI_API_KEY": "your-api-key"
}
}
}
}
If you prefer to keep sensitive credentials separate from configuration files, you can use an environment file approach:
- Create a
.env.cursor
file in your project root with your configurations:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_DATABASE=your_database
DB_SSL=false
# DynAPI Configuration
DYNAPI_URL=http://localhost:4000
DYNAPI_API_KEY=your_api_key
# MCP Server Configuration
MCP_SERVER_NAME=dynapi-mcp
MCP_SERVER_VERSION=1.0.0
CACHE_TTL=3600
LOG_LEVEL=info
- Create a
.cursor/mcp.json
file that references the environment file:
{
"servers": {
"dynapi-intelligence": {
"command": "node",
"args": ["./dist/server.js"],
"cwd": "/path/to/dynapi-mcp",
"envFile": ".env.cursor"
}
}
}
Note: This approach separates credentials from configuration, making it easier to share configuration files without exposing sensitive information.
- Method 1 (Global Settings): Best for personal use when you want the MCP server available across all projects
- Method 2 (Workspace Config): Best when credentials can be included in the config file or when working on a single project
- Method 3 (Environment File): Best for teams/sharing when you need to keep credentials separate from configuration files
You only need to use one of these methods - they're alternatives, not meant to be used together.
Once configured, you can use the DynAPI MCP server directly in Cursor:
- Chat Integration: The MCP tools will be available in Cursor's chat interface
- Code Context: Use
@dynapi-intelligence
to reference the MCP server in conversations - Direct Tool Access: Access tools like
suggest_joins
,build_query
, etc. through chat commands
Example Usage in Cursor Chat:
User: @dynapi-intelligence suggest optimal joins for the mapSolarSystems table
Cursor: I'll analyze the mapSolarSystems table structure and suggest optimal JOIN operations.
[Uses suggest_joins tool]
Result: Here are the recommended JOINs for mapSolarSystems table:
- mapSolarSystems.regionID β mapRegions.regionID (Region information)
- mapSolarSystems.constellationID β mapConstellations.constellationID (Constellation data)
- mapSolarSystems.solarSystemID β mapSystemBodies.solarSystemID (System bodies)
-
Server Not Starting
- Verify the absolute path to
dist/server.js
- Check that all dependencies are installed (
npm install
) - Ensure the server builds successfully (
npm run build
)
- Verify the absolute path to
-
Environment Variables Not Loading
- Use absolute paths for environment files
- Verify
.env
file syntax and permissions - Check Cursor logs for configuration errors
-
Tools Not Available
- Restart Cursor after configuration changes
- Check the MCP server logs for initialization errors
- Verify database and DynAPI connections are working
-
Enable Debug Logging Set
LOG_LEVEL=debug
in your environment configuration to get detailed logs.
This repository includes several template files to help you get started quickly:
cursor-mcp-config.json
- Ready-to-use Cursor MCP server configuration.env.example
- Environment variables template- Copy and modify these files with your actual database and API credentials
User: "I want to find all trading hubs in high-security space"
AI: I'll help you build that query using the DynAPI MCP server.
[Uses build_query tool]
Result:
{
"dynapiQuery": "http://localhost:4000/api/query/mapSolarSystems/solarSystemName,security?hub_eq=true&security_gte=0.5&join=regionID:mapRegions:regionID:regionName&orderBy=regionName",
"explanation": "This query finds solar systems marked as hubs with security >= 0.5, including region names for context"
}
AI: Here's the perfect DynAPI query for finding trading hubs in high-security space:
```bash
curl -H "X-API-Key: your-key" \
"http://localhost:4000/api/query/mapSolarSystems/solarSystemName,security?hub_eq=true&security_gte=0.5&join=regionID:mapRegions:regionID:regionName&orderBy=regionName"
## ποΈ Architecture
dynapi-mcp/ βββ src/ β βββ server.ts # Main MCP server entry point β βββ config/ # Configuration modules β βββ connectors/ # Database and API connectors β βββ analyzers/ # Intelligence and analysis engines β βββ tools/ # MCP tool implementations β βββ types/ # TypeScript type definitions β βββ utils/ # Utility functions βββ dist/ # Compiled JavaScript output βββ docs/ # Additional documentation
## π Scripts
- `npm run build` - Compile TypeScript to JavaScript
- `npm start` - Run the compiled MCP server
- `npm run dev` - Run in development mode with hot reload
- `npm test` - Run test suite
- `npm run lint` - Run ESLint
- `npm run mcp:inspect` - Inspect MCP server with debugging tools
## π Troubleshooting
### Common Issues
1. **Database Connection Errors**
- Verify your database credentials in `.env`
- Ensure PostgreSQL is running and accessible
- Check firewall settings
2. **DynAPI Connection Issues**
- Verify `DYNAPI_URL` is correct
- Check if DynAPI server is running
- Validate your API key
3. **MCP Integration Problems**
- Ensure the compiled server exists in `dist/server.js`
- Check file paths in your MCP configuration
- Verify environment variables are set correctly
### Debug Mode
Enable debug logging:
```bash
LOG_LEVEL=debug npm run dev
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes and add tests
- Run the linter:
npm run lint
- Submit a pull request
MIT License - see LICENSE file for details.
- Advanced query optimization recommendations
- Machine learning-based relationship detection
- Query result caching strategies
- Multi-database support
- GraphQL query generation
- Automated documentation generation