-
Notifications
You must be signed in to change notification settings - Fork 3
Description
📋 Summary
Enable AI agents to manage and operate flAPI configurations through MCP tools. While flAPI already supports creating MCP tools on top of data, this feature adds MCP tools to operate flAPI itself - allowing AI agents to introspect, create, modify, and manage API endpoints, templates, caches, and project configurations.
🎯 Motivation
Currently, flAPI management is done through:
- The REST-based Config Service API (
/api/v1/_config/*) - The
flapiiCLI - The VS Code Extension
AI agents (e.g., Claude, Cursor, Windsurf) that work with flAPI projects would greatly benefit from being able to:
- Discover and introspect existing endpoints
- Create new API endpoints declaratively
- Test and validate SQL templates
- Manage cache refreshes and retention
- Query database schemas for intelligent suggestions
This turns flAPI into a first-class citizen in AI-assisted development workflows, enabling agents to not just consumeflAPI-created tools, but also create and manage them.
🔧 Proposed MCP Tools
The following MCP tools should wrap the existing Config Service handlers (reusing the logic from config_service.cpp):
Project & Configuration Discovery
MCP Tool | Description | Maps to Config Service -- | -- | -- flapi_get_project_config | Get current project configuration | GET /api/v1/_config/project flapi_get_environment_variables | List available environment variables | GET /api/v1/_config/environment-variables flapi_get_filesystem_structure | Get template directory tree with YAML type detection | GET /api/v1/_config/filesystem flapi_get_schema | Introspect database schema (tables, columns, types) | GET /api/v1/_config/schema flapi_refresh_schema | Refresh database schema cache | POST /api/v1/_config/schema/refresh📐 Implementation Approach
Reuse Existing Handler Logic: The MCP tools should delegate to the existing
ConfigServicehandlers (FilesystemHandler,SchemaHandler,EndpointConfigHandler,TemplateHandler,CacheConfigHandler, etc.) rather than duplicating logic.Align with CLI Commands: Tool naming and behavior should mirror
flapiiCLI commands where applicable for consistency.Extend Existing MCP Infrastructure: Build on the current MCP server implementation that already handles
mcp-toolandmcp-resourcedefinitions.Authentication: Respect the existing Config Service token authentication (
X-Config-Token/Authorization: Bearer).Tool Discovery: These tools should be automatically registered when the MCP server starts, similar to how declarative MCP tools from YAML configs are registered.
💡 Example Usage
An AI agent could use these tools to:
Agent: "Create a new API endpoint for querying orders by customer ID"
- flapi_get_schema() → Understand available tables/columns
- flapi_list_endpoints() → Check existing patterns
- flapi_create_endpoint() → Create new endpoint YAML
- flapi_update_template() → Write the SQL template
- flapi_test_template() → Validate with sample parameters
flapi_reload_endpoint() → Hot-reload without restart
🔗 Related
- Existing Config Service:
src/config_service.cpp - MCP Server Implementation:
src/mcp_server.cpp - CLI:
cli/directory - VS Code Extension: Uses Config Service REST API
✅ Acceptance Criteria
- All Config Service operations are exposed as MCP tools
- Tools follow the same input/output schemas as the REST API
- Tools are auto-registered on MCP server startup
- Authentication is enforced consistently
- Documentation updated with new MCP tool definitions
- Integration tests for MCP tool operations