Cody AI Assistant
Connect Lemonado to Sourcegraph Cody using Model Context Protocol
Enterprise-Ready: Cody provides enterprise-grade security and compliance while accessing your Lemonado data through MCP.
Overview
Cody is Sourcegraph's AI coding assistant that understands your entire codebase. With Lemonado's MCP integration, Cody can combine deep code understanding with your business data insights for more intelligent assistance.
Prerequisites
- VS Code with Cody extension installed
- Sourcegraph Cody account (Free or Pro)
- Active Lemonado AI Connector with MCP endpoint
- Node.js installed (for MCP server)
Setup Instructions
Step 1: Install Cody Extension
- Open VS Code
- Go to Extensions (Cmd+Shift+X or Ctrl+Shift+X)
- Search for "Sourcegraph Cody"
- Click Install
- Sign in to your Cody account
Step 2: Configure MCP for Cody
Cody uses a configuration file for MCP servers. Create or edit:
- macOS/Linux:
~/.config/cody/mcp_servers.json - Windows:
%USERPROFILE%\.config\cody\mcp_servers.json
Step 3: Add Lemonado MCP Configuration
Add this configuration to your mcp_servers.json:
{
"cody.mcpServers": {
"lemonado": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-fetch",
"https://mcp.lemonado.io/mcp"
],
"env": {
"MCP_AUTH_TYPE": "oauth",
"MCP_OAUTH_PROVIDER": "lemonado"
}
}
}
}
Step 4: Authenticate with OAuth
When you first use the Lemonado connector, you'll be prompted to authenticate via OAuth. This will open a browser window where you can log in to your Lemonado account and select which AI Connector to use.
Step 5: Restart VS Code
- Close VS Code completely
- Reopen VS Code
- Open Cody chat panel
- Verify the connection with:
@lemonado test connection
Using Lemonado with Cody
Context-Aware Queries
Cody excels at combining code context with data:
How does this CustomerService class relate to @lemonado customer data structure?
Generate a migration to sync this model with @lemonado production schema
Code Generation
Generate code based on real data:
@lemonado Create TypeScript types for our order processing system
Build an API endpoint that matches @lemonado inventory data structure
Data Analysis in Code
Write a function to calculate customer LTV using @lemonado transaction data
@lemonado Generate a report class for our monthly sales metrics
Advanced Features
Cody Commands with MCP
Create custom Cody commands that leverage Lemonado data:
{
"cody.customCommands": [
{
"name": "generate-from-schema",
"prompt": "Generate code based on @lemonado ${input:table} table schema",
"context": {
"selection": true,
"currentFile": true
}
},
{
"name": "validate-against-data",
"prompt": "Validate this code against @lemonado production data patterns"
}
]
}
Multi-Repository Context
Cody can understand relationships across repositories:
How does the API in repo-a interact with @lemonado data used by repo-b?
Enterprise Features
For Cody Enterprise users:
{
"servers": {
"lemonado-prod": {
"command": "node",
"args": ["..."],
"permissions": {
"read": true,
"write": false
},
"audit": true,
"compliance": {
"gdpr": true,
"soc2": true
}
}
}
}
Configuration Options
Environment-Specific Setup
Configure different environments, each with OAuth authentication:
{
"cody.mcpServers": {
"lemonado-dev": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-fetch",
"https://mcp.lemonado.io/mcp"
],
"env": {
"MCP_AUTH_TYPE": "oauth",
"MCP_OAUTH_PROVIDER": "lemonado"
}
},
"lemonado-prod": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-fetch",
"https://mcp.lemonado.io/mcp"
],
"env": {
"MCP_AUTH_TYPE": "oauth",
"MCP_OAUTH_PROVIDER": "lemonado"
}
}
}
}
Cody-Specific Features
Smart Context Selection
Cody automatically includes relevant context:
// Cody understands this relates to customers
class CustomerAnalytics {
// Ask: "@lemonado what fields should this include?"
}
Code Lenses
See data insights directly in your code:
// Cody Lens: 1,234 customers match this query
const premiumCustomers = await db.query(
'SELECT * FROM customers WHERE tier = "premium"'
);
Inline Completions
Get data-aware completions:
const customer = {
id: // Cody suggests: UUID format from @lemonado
name: // Cody suggests: max 255 chars per @lemonado schema
created: // Cody suggests: ISO timestamp format
};
Best Practices
1. Leverage Cody's Context Engine
Let Cody understand your full application:
Explain how @lemonado order data flows through our microservices
2. Use Cody Commands
Create reusable commands for common tasks:
/generate-dto @lemonado.customers
/validate-schema @lemonado.orders
/create-test-data @lemonado.products
3. Combine with Code Search
Find all files that interact with @lemonado customer data
4. Security Best Practices
Security Guidelines:
- OAuth authentication keeps credentials secure
- Authentication happens in your browser
- Monitor access in your Lemonado dashboard
- Disable connectors when not in use
Troubleshooting
Cody Not Finding MCP Server
- Check configuration file location
- Verify JSON syntax
- Ensure Node.js is installed
- Check Cody output panel for errors
Authentication Failures
- Clear browser cookies and re-authenticate
- Check if your AI Connector is active
- Ensure you selected the correct connector during OAuth
Performance Issues
- Enable caching in configuration
- Use specific queries instead of broad searches
- Check VS Code performance monitor
- Upgrade to Cody Pro for better performance
Context Limitations
If Cody's context window is full:
- Use more specific queries
- Clear conversation and start fresh
- Upgrade to Cody Pro for larger context
Integration Patterns
Repository-Aware Queries
How does @lemonado customer data map to our Customer entity across all repos?
Cross-File Understanding
Update all DTOs to match @lemonado latest schema changes
Test Generation
Generate integration tests using @lemonado sample data for edge cases
Documentation
Document this API endpoint with @lemonado real response examples
Cody vs Other AI Assistants
| Feature | Cody | GitHub Copilot | Cursor | Windsurf |
|---|---|---|---|---|
| MCP Support | ✅ Via config | ❌ | ✅ Native | ✅ Native |
| Codebase understanding | ✅ Excellent | ⚠️ Limited | ✅ Good | ✅ Good |
| Enterprise features | ✅ Full | ⚠️ Basic | ❌ | ⚠️ Limited |
| Multi-repo support | ✅ Native | ❌ | ❌ | ❌ |
| Custom commands | ✅ Advanced | ❌ | ⚠️ Basic | ✅ Good |
| On-premise option | ✅ Available | ❌ | ❌ | ❌ |
Enterprise Deployment
Self-Hosted Setup
For enterprise customers with self-hosted Sourcegraph:
{
"cody.mcpServers": {
"lemonado": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-fetch",
"https://mcp.lemonado.io/mcp"
],
"env": {
"MCP_AUTH_TYPE": "oauth",
"MCP_OAUTH_PROVIDER": "lemonado"
},
"proxy": "https://your-sourcegraph-instance.com/proxy"
}
}
}
Compliance Features
- SOC 2 Type II compliant
- GDPR data handling
- Audit trail for all queries
- Role-based access control
Team Sharing
Share MCP configurations across your team:
# Export configuration
cody config export --mcp > team-mcp-config.json
# Import on team member's machine
cody config import --mcp team-mcp-config.json
Tips & Tricks
Quick Data Checks
Use Cody's inline chat for quick queries:
// Cmd+I: "@lemonado count of active users"
Refactoring with Data
Refactor this service to handle @lemonado new payment types
Performance Optimization
Analyze this query against @lemonado indexes and suggest optimizations
Schema Validation
Validate our TypeScript interfaces against @lemonado current schema
Next Steps
- Explore Cody documentation
- Learn about MCP protocol
Pro Tip: Use Cody's "Explain" command on complex queries to understand how your code interacts with Lemonado data and get optimization suggestions.