|
| 1 | +--- |
| 2 | +title: "Using Github Copilot with Convex" |
| 3 | +sidebar_position: 200 |
| 4 | +description: "Tips and best practices for using Github Copilot with Convex" |
| 5 | +slug: "using-github-copilot" |
| 6 | +--- |
| 7 | + |
| 8 | +[Github Copilot](https://github.com/features/copilot), the AI built into VSCode, |
| 9 | +makes it easy to write and maintain apps built with Convex. Let's walk through |
| 10 | +how to setup Github Copilot for the best possible results with Convex. |
| 11 | + |
| 12 | +## Add Convex Instructions |
| 13 | + |
| 14 | +Add the following |
| 15 | +[instructions](https://code.visualstudio.com/docs/copilot/copilot-customization#_instruction-files) |
| 16 | +file to your `.github/instructions` directory in your project and it will |
| 17 | +automatically be included when working with Typescript or Javascript files: |
| 18 | + |
| 19 | +- [convex.instructions.md](https://convex.link/convex_github_copilot_instructions) |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +If you would rather that the instructions file is NOT automatically pulled into |
| 24 | +context then open the file in your editor and alter the `applyTo` field at the |
| 25 | +top. Read more about instructions files here: |
| 26 | +https://code.visualstudio.com/docs/copilot/copilot-customization#_use-instructionsmd-files |
| 27 | + |
| 28 | +We're constantly working on improving the quality of these rules for Convex by |
| 29 | +using rigorous evals. You can help by |
| 30 | +[contributing to our evals repo](https://github.com/get-convex/convex-evals). |
| 31 | + |
| 32 | +## Setup the Convex MCP Server |
| 33 | + |
| 34 | +The Convex CLI comes with a |
| 35 | +[Convex Model Context Protocol](/ai/convex-mcp-server.mdx) (MCP) server built |
| 36 | +in. The Convex MCP server gives your AI coding agent access to the your Convex |
| 37 | +deployment to query and optimize your project. |
| 38 | + |
| 39 | +To get started with |
| 40 | +[MCP in VSCode](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) |
| 41 | +then create a file in `.vscode/mcp.json` and add the following: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "servers": { |
| 46 | + "convex-mcp": { |
| 47 | + "type": "stdio", |
| 48 | + "command": "npx", |
| 49 | + "args": ["-y", "convex@latest", "mcp", "start"] |
| 50 | + } |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +Once this is done it will take a few seconds to start up the MCP server and then |
| 56 | +you should see the Convex tool listed in the codelens: |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +and in the selection of tools that the model has access to in chat: |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +Now start asking it questions like: |
| 65 | + |
| 66 | +- Evaluate and convex schema and suggest improvements |
| 67 | +- What are this app's public endpoints? |
| 68 | +- Run the `my_convex_function` query |
| 69 | + |
| 70 | +If you want to use the MCP server globally for all your projects then you can |
| 71 | +add it to your user settings, please see these docs for more information: |
| 72 | +https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server-to-your-user-settings |
0 commit comments