Module 1: Supercharge Your IDE with MCP
Create and optimize a GitHub MCP Server with Agentic RAG
Module Summary
- Goal: Create a custom GitHub MCP Server with Agentic RAG optimization
- Estimated Time: 15-20 minutes
- Prerequisites: GitHub account, Cursor IDE, xpander.ai account
🚀 In this module, you’ll learn how to build a powerful GitHub search agent with optimized Agentic RAG capabilities and expose it as a Model Context Protocol (MCP) Server to supercharge your Cursor IDE experience. By building this agent, you’ll understand how to create practical AI tools that integrate seamlessly with your development workflow, improving coding efficiency and access to real-time code examples.
🔍 Creating Your GitHub Search Agent
Step 1: Set up xpander.ai
-
Navigate to the xpander.ai platform:
Terminal Command -
Sign in with your credentials
-
In the left navigation menu, go to AI Agents
-
Click the New AI Agent button to open the Workbench
-
When prompted by the agent builder, click Skip (we’ll create the agent manually)
Step 2: Configure Agent Settings
-
In the Builder Workbench, click on the Gear Icon in the top-right corner
-
In the Agent Builder Settings panel, click on Generate Details
-
Enter the following prompt to generate your agent description:
Prompt for generating agent -
Now define your agent’s role, goal, and instructions:
RoleGoalInstructions -
Click Save Changes and close the panel
Step 3: Add GitHub Search Tools
-
Click on the + (plus) button in your agent canvas
-
Select Apps from the menu
-
Select GitHub Search Manager
-
Click Sign in with GitHub Search Manager
-
Give the interface a name (like “github-search-your-name” or just “github-search”)
-
Click Save
You should now see the GitHub Search tools available as Agentic Actions in your agent’s canvas.
Step 4: Add GitHub Operations
Add the following GitHub operations to your agent:
- Find Code Snippets by Query Terms -
GET /search/code
- Find Repositories by Criteria -
GET /search/repositories
- Search Topics by Criteria -
GET /search/topics
- Find Users by Criteria -
GET /search/users
- Search Commits by Criteria -
GET /search/commits
Your completed agent should look similar to this:
🧪 Testing Your Agent with Raw API Responses
Let’s test your newly created GitHub search agent:
-
Click on the Tester tab in the xpander.ai interface
-
Type the following query to search for topics:
Prompt -
Look at the generated payload by clicking on it. You’ll see something like:
Example AI Generated PayloadExample response -
Now try a repositories search:
PromptAI Generated payload
Notice that the API response is huge and not optimal for AI consumption! This is where Agentic RAG comes in to help filter and optimize these responses.
🧠 Optimizing Responses with Agentic RAG
Optimizing Repository Search
Let’s improve the repository search results using Agentic RAG:
-
Return to the Builder tab
-
Click on the gear icon next to the Find Repositories by Criteria operation
-
Click on Advanced and then switch to Raw Editor (this allows the AI to send natural language queries, and the server will perform semantic search on the API response)
-
Configure the search and return fields:
Searchable Fields (fields the AI can search against):
Searchable Fields ConfigurationReturnable Fields (data the AI will receive):
Returnable Fields Configuration -
Save your changes
-
Return to the Tester tab and run the repositories query again:
Prompt
Notice how much cleaner and more focused the response is now! Instead of overwhelming JSON data, you get just the meaningful content that matters to your query.
Optimizing User Search
Next, let’s optimize the user search operation:
-
Return to the Builder tab
-
Click on the gear icon next to the Find Users by Criteria operation
-
Go to Advanced → Raw Editor
-
Configure the fields:
Searchable Fields:
User Search ConfigurationReturnable Fields:
User Return Configuration -
Save your changes
-
In the Tester tab, run:
Prompt
Optimizing Commit Searches
Now, let’s configure commit search operations:
-
Return to the Builder tab
-
Click on the gear icon next to the Search Commits by Criteria operation
-
Go to Advanced → Raw Editor
-
Configure the fields:
Searchable Fields:
Commit Search ConfigurationReturnable Fields:
Commit Return Configuration -
Save your changes
-
In the Tester tab, try a follow-up question:
Follow-up Prompt
Optimizing Code Snippets Search
Finally, let’s optimize the code snippet operation:
-
Return to the Builder tab
-
Click on the gear icon next to the Find Code Snippets by Query Terms operation
-
Go to Advanced → Raw Editor
-
Configure the fields:
Searchable Fields:
Searchable Fields ConfigurationReturnable Fields:
Returnable Fields Configuration -
Save your changes
-
In the Tester tab, run:
Prompt
The optimized results should look similar to this:
📄 Adding Code Reading Capabilities
Let’s enhance our agent by adding the ability to read code directly from GitHub URLs:
- In the left navigation menu, go to Cloud Functions
- Click the New button
- Add the following code:
- Name it GitHub Code Reader and click Save
- Return to your agent in the AI Agents section
- Click the + button
- Select Custom Action
- Add the GitHub Code Reader function to your agent canvas
- Click Save -> Deploy.
Run the following prompt
The screenshot is from the agent’s WebUI. You can access yours by clicking the ‘Chat’ button on the canvas — the WebUI URL will appear
🌎 Enhancing Your Agent with Web Search
Your GitHub search agent currently can only access information available on GitHub. Let’s add web search capabilities to make it more versatile:
-
Return to your agent canvas
-
Click the + button
-
Select Built-in Actions
-
Add Fetch Tavily AI Insights (for comprehensive web searching)
-
Click on the gear icon in your agent canvas to edit the agent settings
-
Update your agent’s instructions by adding these important rules:
Updated Instructions -
Save your changes
-
In the Tester tab, try a query that requires recent information:
Test Prompt
Your agent should now provide more comprehensive answers by combining web search results with GitHub code examples:
Sometimes, our autonomous agent might choose to use GitHub before Tavily, despite our explicit instructions. This happens because the AI model sees all available tools at once and makes decisions based on its understanding of the prompt and tool descriptions.
This reveals a fascinating design challenge in AI systems: How can we create truly autonomous agents capable of making intelligent decisions while ensuring they reliably follow critical business logic when needed? 🤔
🔄 Creating the Agent Dependency Graph
In production, to ensure your agent follows the right search strategy, we should always create a dependency graph that deterministically enforces specific business logic behavior:
- In your agent canvas, click on the Graph View button
- Set up a workflow that requires an internet search before accessing GitHub operations:
- Connect the Tavily AI Insights node as a prerequisite to the GitHub operations
- Ensure the flow follows a logical progression
- Repeat the query with explict request to not start with Tavily
- Validate additonal queries:
- Verify that the AI follows the correct workflow - first searching for information before accessing GitHub operations:
Congratulations! You’ve built a reliable AI Agent that balances autonomy with guardrails. By creating this structured workflow, you’ve effectively addressed both the API overflow challenge and solved the autonomous multi-step challenges
🌐 Exposing Your Agent as an MCP
The final step is to expose your optimized GitHub agent as a Model Context Protocol (MCP) server:
- In your agent canvas, click the + button
- Select Source → MCP
- Click Deploy
-
After deployment, you’ll receive a unique URL for your MCP server
-
Configure this endpoint in your Cursor IDE by editing the settings file:
Create or edit
~/.cursor/mcp.json
:mcp.jsonMake sure to replace
https://mcp.xpander.ai/your-server-url/
with your actual MCP server URL from the deployment step! -
Restart Cursor IDE to apply the changes
-
Test your MCP integration by asking a question in Cursor:
Prompt to Agent (via MCP)
✅ Checkpoint
Congratulations! By completing this module, you should now be able to:
- Create and configure a GitHub search agent with optimized Agentic RAG
- Customize searchable and returnable fields for each API operation
- Add custom code reading capabilities to your agent
- Structure agent workflows using dependency graphs
- Deploy your agent as an MCP endpoint for Cursor IDE
🔄 Next Steps
Now that you’ve supercharged your IDE with an optimized GitHub MCP Server, you’re ready to build your first coding agent in the next module.