-
Notifications
You must be signed in to change notification settings - Fork 64
Migrations in MCP #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add Neon logo - Add link to related blog
## Description This PR aims to setup Neon's MCP server evaluation. **FEATURES** - Refactor MCP Client to serve as the testing client - Add the 1st evaluation to the `prepare_database_migration` MCP Server tool - Adapt the `prepare_database_migration` tool to be way more deterministic - Add command to run evaluation locally ## Test Plan In 172 test runs, with 9 different prompts, we had a 96% factuality check rate for the `prepare_database_migration` prompt, meaning that the tool behaved very much as expected for most of the time. Experiments: https://www.braintrust.dev/app/Neon%20Inc./p/prepare_database_migration/experiments/mcp-evaluation-1735815763?c=mcp-evaluation-1735810092&tc=985c1e51-a5d6-49dd-93cf-a05eef322064&s=51591878-c460-46d7-8852-e65893592d22 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orca Security Scan Summary
Status | Check | Issues by priority | |
---|---|---|---|
![]() |
Secrets | ![]() ![]() ![]() ![]() |
View in Orca |
extended from #14 - As we use bun during build stage, `node:alpine` docker image is not enough - Update the MCP command --------- Co-authored-by: Henry Mao <1828968+calclavia@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orca Security Scan Summary
Status | Check | Issues by priority | |
---|---|---|---|
![]() |
Secrets | ![]() ![]() ![]() ![]() |
View in Orca |
🔑 The following Secrets have been detected in your pull request across all commits
NAME | FILE | LINE NUM | COMMIT | ||
---|---|---|---|---|---|
![]() |
.env File | ...-client/.env.example | 1 | View in code | |
![]() |
.env File | .env.example | 1 | View in code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orca Security Scan Summary
Status | Check | Issues by priority | |
---|---|---|---|
![]() |
Secrets | ![]() ![]() ![]() ![]() |
View in Orca |
The previous commands for smithery did not start the server correctly.
Add Neon MCP Server Guides
introduce eslint configuration ensuring typschek, linters and prettier.
We can have a tool that simply returns the connection string. The problem with connection strings is that they are much more complex than they appear on surface. You have to pick: - Project ID - Branch - Compute - Default Database - Role So, in theory, a proper tool to get a connection string would need to receive these 5 thing as input, with ALL of them being optional because there are cases when there is only one available choice for ALL of them, in which case the MCP server should just be able to return the connection string for: - Your only project - Its only branch - Its only endpoint/compute - Its only database - The only role (probably neondb_owner) I decided to make Project ID mandatory, I'm not sure having that as optional is a good idea. CC @Shridhad
- [x] Upgrade Neon API Client version - [x] Add new tool `provision_neon_auth` to auto provision Neon Auth with Stack - [x] Add database as optional parameter cc: @pffigueiredo
# Query Tuning Feature Implementation This PR introduces a comprehensive query tuning system for PostgreSQL databases in Neon. ## New Features ### 1. Query Performance Analysis Tools - Added `explain_sql_statement` tool for analyzing query execution plans - Implemented `prepare_query_tuning` for suggesting performance optimizations - Added `complete_query_tuning` for applying or discarding optimizations ### 2. Enhanced Table Description System - Added new `describeUtils.ts` module for detailed table analysis - Provides comprehensive information about: - Column definitions and metadata - Index information with sizes - Table constraints - Table and index size metrics ### 3. Improved State Management - Added tuning state management alongside existing migration state - New types and interfaces for tracking query tuning sessions - Support for temporary branches during optimization testing ### 4. Logging System ~~- Introduced new logging module (`logger.ts`)~~ ~~- Provides structured logging for debugging and monitoring~~ ~~- Logs are stored in user's home directory~~ ## Infrastructure Updates - Added role name support across database operations - Enhanced connection string handling - Updated API client configuration with staging URL - Improved error handling and retry mechanisms ## Technical Improvements - Better parameter handling in database operations - Enhanced SQL execution with role-based access - Improved table schema analysis with detailed metadata - Added support for temporary branches in query optimization workflow This feature enables developers to analyze and optimize query performance through a structured workflow, with safe testing in temporary branches before applying changes to production. --------- Co-authored-by: Alexander Bayandin <alexander@bayandin.dev>
Fixed the following lint issues - Unused imports and variables - Unnecessory try-catch blocks
- [x] Refactor the app to start in both `stdio` and `sse` mode - [x] Using express for `sse` - we can switch to Fastify or something else in future - [x] Added `morgan` for API access logs - [x] Added `winston` for App logs - [x] Implement the OAuth flow as a middle - [x] Using `keyv` and Neon for store tokens and auth codes - [x] Implement the `refresh_token` flow - [x] ~Testing on Vercel~ Deploy on Fly - [x] Security review for OAuth flow - PKCE code exchange, client-secret verification cc: @davidgomes --------- Co-authored-by: David Gomes <davidrafagomes@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: david@neon.tech <david@neon.tech>
I tried to make a test for this, but unfortunately it's hard to verify that this is _actually_ working as a fix. Most of the time, Claude is smart and it will pass the `search` parameter which means that the limit is not actually a problem. So, we'll have to vibe-trust this PR unfortunately. CC @Shridhad --------- Co-authored-by: Shridhar Deshmukh <shridhar@neon.tech>
Tool: `list_slow_queries` Params: projectId, branchId, database, limit (10), minExecutionTime(1000ms), timeRange(1h) Requirement: The tool requires `pg_state_statements` extension to be installed to find query execution times <img width="745" alt="Screenshot 2025-05-02 at 19 42 36" src="https://github.com/user-attachments/assets/98bbe589-131f-4742-a30c-f391af738a7f" /> <img width="770" alt="Screenshot 2025-05-02 at 19 42 59" src="https://github.com/user-attachments/assets/37edb5d6-3216-4654-92b7-20384a274bf4" /> --------- Co-authored-by: Shridhar Deshmukh <shridhar@neon.tech>
# Add list_branch_computes tool This PR adds a new tool called `list_branch_computes` that allows listing compute endpoints for a project or specific branch. The tool: - Takes optional ProjectId and BranchId parameters - Uses listProjectBranchEndpoints API when BranchId is provided - Uses listProjectEndpoints API when BranchId is not provided - Returns compute_id, compute_type, compute_size, and last_active fields for all computes - Includes both min and max sizes in the compute_size field when autoscaling is enabled - Includes additional fields in the output beyond the required ones ## Testing - Linting passes with `npm run lint` Link to Devin run: https://app.devin.ai/sessions/d56807b39aa942bca9dc1cf88b3fbf7c Requested by: shridhar@neon.tech cc: @davidgomes Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: shridhar@neon.tech <shridhar@neon.tech>
# Update README with new MCP Server tools This PR updates the README.md to include documentation for the new MCP Server tools: - Added `list_branch_computes` tool to the Branch Management section - Added `list_slow_queries` tool to the SQL Query Execution section - Added a new Query Performance Tuning section with: - `explain_sql_statement` tool - `prepare_query_tuning` tool - `complete_query_tuning` tool - Updated the `list_projects` tool description to mention the default limit feature ## Changes - Added new tools to the README.md Supported Tools section Link to Devin run: https://app.devin.ai/sessions/d88f241ca0384215a08c5d8fdd95ca11 Requested by: Daniel Price (daniel@neon.tech) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Daniel Price <daniel@neon.tech>
Render the MCP client details for approval from the user before proceeding to authentication and authorization. The approval displays - Client's Name, Website, and Redirect URIs. The approvals are persisted in signed cookies and not shown for subsequent auth requests. <img width="894" alt="Screenshot 2025-05-12 at 18 09 21" src="https://github.com/user-attachments/assets/ca6b7545-128d-40fa-a53a-886295f17e8d" /> cc: @pffigueiredo
- [x] Add support for `client_secret_basic` auth method, supports client credentials in `Authorization` header during token exchange flow - [x] Skip client_secret verification for public clients - [x] Make PKCE challenge optional, and instead add `redirect_uri` verification for token exchange cc: @andrelandgraf @pffigueiredo
- [x] Fix the `npx @neondatabase/mcp-server-neon start` command to start in STDIO mode instead of SSE mode. - [x] Disable logging in STDIO mode, the error logs to stderr cause the errors in the host application (Claude Desktop) because wrong format - [Docs](https://modelcontextprotocol.io/docs/tools/debugging#server-side-logging) cc: @pffigueiredo
- [x] Identify users on SSE connections and standalone starts - [x] Track Evens - [x] Tool Calls - [x] Resource Calls - [x] Server Errors - [x] `WRITE_KEY` in bundle for standalone mode cc: @pffigueiredo
- [x] Instrument Sentry and capture errors/exceptions - [x] Tracing with Sentry The tracking is collected in Sentry project - mcp-server - [Issues](https://neondatabase.sentry.io/issues/?project=4509328350380033&referrer=sidebar&statsPeriod=14d) and [Tracing](https://neondatabase.sentry.io/traces/?project=4509328350380033&statsPeriod=14d) <img width="1440" alt="sentry-tracing" src="https://github.com/user-attachments/assets/beb6a903-780e-4f21-a94b-eb42c3763af6" /> cc: @pffigueiredo
For a free organization feature, new projects should be created in the default organization and not under a personal account. This PR adds additional logic to resolve the user's organization for `list_projects` and `create_project` tools Resolution: 1. Fetch user details and verify if the project can be created under a personal/individual account. If yes, proceed with the tool execution 2. If not, the user should have a free organization. Fetch and filter organizations managed by `console` 3. If the filter results in only one organization, execute the tool under this organization scope 4. If the filter returns multiple orgs, throw error requesting user/agent for an `org_id` cc: @pffigueiredo @davidgomes
The `tools.ts` file was growing out of control with tool definitions, types, and handlers; splitting it into smaller modules, which, for now, provides type reusability. cc: @davidgomes
Add support for streamable-http - `https://mcp.neon.tech/mcp` preview: https://preview-mcp-server-neon.fly.dev/ cc: @pffigueiredo
…d actualy works (#73) Co-authored-by: Shridhar Deshmukh <shridhar@neon.tech>
Closing as this PR is created in reverse. Will open new one when work is prioritized |
No description provided.