model context protocol
Model Context Protocol (MCP) allows twig's agent to access external tools and data sources beyond your local codebase.
what is mcp?
MCP is a standard protocol for connecting AI agents to external resources:
- Databases (PostgreSQL, MySQL, MongoDB)
- APIs (REST, GraphQL)
- Documentation systems
- File systems beyond your project
- Third-party services
Instead of the agent being limited to your local files, MCP lets it query databases, fetch API data, and access other resources you configure.
how it works
MCP uses "servers" - small programs that provide access to specific resources. Each server knows how to communicate with one type of resource (like a database or an API).
Example workflow:
- You set up an MCP server for your PostgreSQL database
- You ask the agent: "How many users signed up this week?"
- The agent queries your database through the MCP server
- You get the answer without leaving twig
important: setup location
MCP configuration happens in Claude, not in twig.
Twig uses Claude's Agent SDK, which means MCP servers are configured in your Claude settings, not in twig's interface. Once configured in Claude, they're automatically available in twig.
setting up mcp
1. configure in claude
MCP servers are set up through Claude's configuration:
- Open your Claude configuration (location depends on your setup)
- Add MCP server definitions
- Configure authentication and connection details
Example configuration format:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
}
}
}
2. verify in twig
Once configured in Claude:
- Open twig
- Ask the agent a question that requires the external resource
- The agent will use the MCP server automatically
common mcp servers
databases
- PostgreSQL - query PostgreSQL databases
- SQLite - access SQLite files
- MongoDB - query MongoDB collections
apis
- REST API server - make HTTP requests to REST APIs
- GraphQL server - query GraphQL endpoints
file systems
- Filesystem server - access files outside your project
- Google Drive server - read documents from Google Drive
documentation
- Web search server - fetch documentation from URLs
- Knowledge base server - access internal docs
use cases
development with real data
how many users have the premium feature enabled?
The agent queries your database through MCP instead of you having to check yourself.
api integration
what's the current exchange rate from our payment provider's api?
The agent fetches live data through MCP.
cross-project references
how is this feature implemented in our other project?
The agent can access files from another project through an MCP filesystem server.
documentation lookup
what's the recommended way to handle authentication according to our internal docs?
The agent fetches information from your docs system.
limitations
requires external setup
MCP servers must be configured outside of twig, in your Claude configuration. This requires:
- Familiarity with configuration files
- Access to set up servers
- Understanding of the resources you're connecting to
not automatic
MCP servers don't configure themselves. You need to:
- Install MCP server packages
- Configure connection details
- Manage authentication
- Troubleshoot connection issues
security considerations
MCP gives the agent access to external resources. Consider:
- What data the agent can access
- Authentication and authorization
- Read-only vs write access
- Sensitive information exposure
Only configure MCP servers for resources you're comfortable giving the agent access to.
getting started with mcp
- Identify a need - what external resource would help your development?
- Find or create a server - look for existing MCP servers or build one
- Configure in Claude - add the server to your Claude configuration
- Test in twig - ask questions that require the external resource
- Refine - adjust configuration based on what works
troubleshooting
agent doesn't use mcp server
- Verify the server is configured in Claude, not just twig
- Check that the agent can see the server (ask "what MCP servers are available?")
- Ensure connection details are correct
connection errors
- Verify authentication credentials
- Check network access to the resource
- Review server logs for specific errors
unexpected results
- Check what data the server is returning
- Verify the agent is asking the right questions to the MCP server
- Review server capabilities (some servers have limitations)
learning more
For detailed MCP documentation:
- MCP specification - official protocol docs
- Available MCP servers - pre-built servers
- Claude configuration guide - setting up MCP in Claude
related pages
- agent tools - built-in capabilities
- rules - persistent instructions
- glossary - key terms