feat(mcp): add MCP server plugin for natural language SQL queries on DevLake normalized schema#10
Open
irfanuddinahmad wants to merge 4 commits into
Open
Conversation
…normalized schema Adds a new DevLake plugin at backend/plugins/mcp/ that exposes an MCP (Model Context Protocol) server over Streamable HTTP, allowing AI assistants such as Claude Code to query DevLake's normalized domain data using natural language. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
irfanuddinahmad
changed the base branch from
main
to
feature/hubspot-notion-plugins
May 18, 2026 12:59
- replace stale hard-coded schema registry with domain-model-driven schema discovery - expose QA tables in MCP table listing - harden read-only SQL validation and reject multiple statements - add MCP plugin to plugin coverage test - add focused handler tests
…ancements fix(mcp): derive schema from domain models and harden MCP handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new DevLake backend plugin (
backend/plugins/mcp/) that exposes a Model Context Protocol (MCP) server over Streamable HTTP. This enables AI assistants (Claude Code, Cursor, or any MCP-compatible client) to query DevLake's normalized domain data using natural language — the assistant discovers the schema, writes SQL, and executes it, all through the MCP tool protocol.Architecture
The plugin follows the MCP Streamable HTTP stateless transport — each POST is a complete, self-contained JSON-RPC 2.0 exchange with no session state.
Plugin structure
No new database tables, no migrations, no subtasks — this is a pure API plugin.
MCP Tools exposed
list_tablescode,ticket,devops,crossdomain,codequality,ai). Accepts optionaldomainfilter.get_schemaexecute_querySELECT(orWITH … SELECT) query against the DevLake database. Results capped at 500 rows.Security
SELECTandWITH … SELECTstatements are accepted; all DDL and DML keywords (INSERT,UPDATE,DELETE,DROP,CREATE,ALTER,TRUNCATE,EXEC, etc.) are rejected.LIMIT 500subquery wrapper is added automatically when noLIMITclause is present.[]bytecolumns (MySQL text/blob) are converted to strings for clean JSON output.Normalized schema coverage
The embedded schema registry covers all major domain layer tables:
repos,commits,pull_requests,pull_request_commits,pull_request_labels,pull_request_reviewers,refs,repo_commits,commit_filesissues,issue_labels,issue_changelogs,issue_worklogs,boards,sprints,sprint_issues,board_issuescicd_scopes,cicd_pipelines,cicd_tasks,cicd_deployment_commits,cicd_pipeline_commits,cicd_releasesusers,accounts,teams,pull_request_issues,issue_commits,project_mappingcq_projects,cq_issues,cq_file_metricsai_activitiesUsage
1. Build and enable the plugin
2. Configure MCP client (Claude Code example)
Add to
~/.claude.jsonor project.mcp.json:{ "mcpServers": { "devlake": { "url": "http://localhost:8080/api/plugins/mcp/mcp" } } }Or via CLI:
3. Example queries
Once connected, an AI assistant can answer questions like:
The assistant calls
list_tables→get_schema→execute_queryautomatically.Test plan
go build ./plugins/mcp/...passes with no errorsgo vet ./plugins/mcp/...passes cleanPOST /api/plugins/mcp/mcpwith{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}returns a validinitializeResulttools/listreturns all three tool definitionstools/callwithlist_tablesreturns domain-grouped table listtools/callwithget_schemaforpull_requestsreturns correct columnstools/callwithexecute_queryand a valid SELECT returns rows as JSONexecute_querywithDROP TABLE issuesis rejected with a clear errorexecute_querywithout a LIMIT clause gets capped to 500 rows automatically🤖 Generated with Claude Code