Agent connector tutorial: FastMCP
In this tutorial, you'll create a new Python project with uv, build a FastMCP server that exposes one of Airbyte's agent connectors as an MCP tool, and use it to query GitHub data from any MCP-compatible agent. This tutorial uses GitHub, but if you don't have a GitHub account, you can use one of Airbyte's other agent connectors and perform different operations.
Overview
This tutorial is for AI engineers and other technical users who work with data and AI tools. You can complete it in about 15 minutes.
The tutorial assumes you have basic knowledge of the following tools, but most software engineers shouldn't struggle with anything that follows.
- Python and package management with uv
- MCP (Model Context Protocol) and MCP servers
- GitHub, or a different third-party service you want to connect to
Before you start
Before you begin this tutorial, ensure you have the following.
- Python version 3.13 or later
- uv
- A GitHub personal access token. For this tutorial, a classic token with
reposcope is sufficient. - An agent that supports MCP servers, such as Claude Desktop, Claude Code, or Cursor.
Part 1: Create a new Python project
Create a new project using uv:
uv init my-mcp-agent --app
cd my-mcp-agent
This creates a project with the following structure:
my-mcp-agent/
├── .gitignore
├── .python-version
├── main.py
├── pyproject.toml
└── README.md
Part 2: Install dependencies
Install the GitHub connector and FastMCP:
uv add airbyte-agent-github fastmcp
This command installs:
airbyte-agent-github: The Airbyte agent connector for GitHub, which provides type-safe access to GitHub's API.fastmcp: A Python framework for building MCP servers with minimal boilerplate.
The GitHub connector also includes python-dotenv, which you can use to load environment variables from a .env file.
Part 3: Import FastMCP and the GitHub agent connector
-
Create a
server.pyfile for your MCP server definition:touch server.py -
Add the following imports to
server.py:server.pyimport os
import json
from dotenv import load_dotenv
from fastmcp import FastMCP
from airbyte_agent_github import GithubConnector
from airbyte_agent_github.models import GithubPersonalAccessTokenAuthConfigThese imports provide:
osandjson: Access environment variables and serialize connector results.load_dotenv: Load environment variables from your.envfile.FastMCP: The FastMCP server class that handles MCP protocol communication.GithubConnector: The Airbyte agent connector that provides type-safe access to GitHub's API.GithubPersonalAccessTokenAuthConfig: The authentication configuration for the GitHub connector using a personal access token.
Part 4: Add a .env file with your secrets
-
Create a
.envfile in your project root and add your GitHub token to it. Replace the placeholder value with your actual credential..envGITHUB_ACCESS_TOKEN=your-github-personal-access-tokenwarningNever commit your
.envfile to version control. If you do this by mistake, rotate your secrets immediately. -
Add the following line to
server.pyafter your imports to load the environment variables:server.pyload_dotenv()
Part 5: Configure your connector and MCP server
Now that your environment is set up, add the following code to server.py to create the GitHub connector and FastMCP server.
Create the server and connector
mcp = FastMCP("GitHub Agent")
connector = GithubConnector(
auth_config=GithubPersonalAccessTokenAuthConfig(
token=os.environ["GITHUB_ACCESS_TOKEN"]
)
)
FastMCP("GitHub Agent")creates a new MCP server named "GitHub Agent".- The connector authenticates using your personal access token.
Register the tool
Register the connector's execute method as an MCP tool. The @GithubConnector.tool_utils decorator automatically generates a comprehensive tool description from the connector's metadata. This tells the agent what entities are available (issues, pull requests, repositories, etc.), what actions it can perform on each entity, and what parameters each action requires.
@mcp.tool()
@GithubConnector.tool_utils
async def github_execute(entity: str, action: str, params: dict | None = None) -> str:
"""Execute GitHub connector operations."""
result = await connector.execute(entity, action, params or {})
return json.dumps(result, default=str)
With this single tool, your MCP server exposes all of the connector's capabilities. The agent decides which entity and action to use based on your natural language questions.
Add the server entry point
Add the following at the bottom of server.py to start the server when run directly:
if __name__ == "__main__":
mcp.run()
Part 6: Register with your agent
Register the MCP server with your preferred agent. Provide the full path to your project's server.py file. Replace /path/to/my-mcp-agent with the actual path to your project directory.
- Claude Code
- Claude Desktop
- Cursor
claude mcp add github-agent -- uv run --directory /path/to/my-mcp-agent server.py
Add the following to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"github-agent": {
"command": "uv",
"args": ["run", "--directory", "/path/to/my-mcp-agent", "server.py"]
}
}
}
On macOS, the config file is at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows, it's at %APPDATA%\Claude\claude_desktop_config.json.
Add the following to your Cursor MCP configuration file (.cursor/mcp.json in your project directory, or ~/.cursor/mcp.json for global configuration):
{
"mcpServers": {
"github-agent": {
"command": "uv",
"args": ["run", "--directory", "/path/to/my-mcp-agent", "server.py"]
}
}
}
Part 7: Use the MCP server
-
Restart your agent so it picks up the new MCP server registration.
-
Once restarted, prompt your agent with natural language questions about your GitHub data. Try prompts like:
- "List the 5 most recent open issues in airbytehq/airbyte"
- "Show me the latest pull requests in my-org/my-repo"
- "What are the open issues assigned to octocat?"
Your agent discovers the MCP server's tools automatically and calls them based on your prompts. The MCP server handles executing the connector operations and returning the results.
Troubleshooting
If your agent fails to retrieve GitHub data, check the following:
- Server not found: Ensure the path in your MCP configuration points to the correct
server.pyfile and thatuvis available on your system PATH. - HTTP 401 errors: Your
GITHUB_ACCESS_TOKENis invalid or expired. Generate a new token and update your.envfile. - HTTP 403 errors: Your
GITHUB_ACCESS_TOKENdoesn't have the required scopes. Ensure your token hasreposcope for accessing repository data.
Summary
In this tutorial, you learned how to:
- Set up a new Python project with uv
- Add FastMCP and Airbyte's GitHub agent connector to your project
- Configure environment variables and authentication
- Build a FastMCP server that exposes the GitHub connector as an MCP tool
- Register the MCP server with your agent and query data using natural language
Next steps
-
Add more agent connectors to your project. Explore other agent connectors in the Airbyte agent connectors catalog to give your MCP server access to more services like Stripe, HubSpot, and Salesforce. You can register multiple tools on the same FastMCP server.
-
Consider how you might like to expand your MCP server. For example, you can add MCP prompts to provide reusable prompt templates, or MCP resources to expose data directly. See the FastMCP documentation for more options.