airbyte.mcp.server
Experimental MCP (Model Context Protocol) server for PyAirbyte connector management.
1# Copyright (c) 2024 Airbyte, Inc., all rights reserved. 2"""Experimental MCP (Model Context Protocol) server for PyAirbyte connector management.""" 3 4import asyncio 5import sys 6 7from fastmcp import FastMCP 8 9from airbyte._util.meta import set_mcp_mode 10from airbyte.mcp._util import initialize_secrets 11from airbyte.mcp.cloud_ops import register_cloud_ops_tools 12from airbyte.mcp.connector_registry import register_connector_registry_tools 13from airbyte.mcp.local_ops import register_local_ops_tools 14from airbyte.mcp.prompts import register_prompts 15 16 17# ============================================================================= 18# Server Instructions 19# ============================================================================= 20# This text is provided to AI agents via the MCP protocol's "instructions" field. 21# It helps agents understand when to use this server's tools, especially when 22# tool search is enabled. For more context, see: 23# - FastMCP docs: https://gofastmcp.com/servers/overview 24# - Claude tool search: https://www.anthropic.com/news/tool-use-improvements 25# ============================================================================= 26 27MCP_SERVER_INSTRUCTIONS = """ 28PyAirbyte connector management and data integration server for discovering, 29deploying, and running Airbyte connectors. 30 31Use this server for: 32- Discovering connectors from the Airbyte registry (sources and destinations) 33- Deploying sources, destinations, and connections to Airbyte Cloud 34- Running cloud syncs and monitoring sync status 35- Managing custom connector definitions in Airbyte Cloud 36- Local connector execution for data extraction without cloud deployment 37- Listing and describing environment variables for connector configuration 38 39Operational modes: 40- Cloud operations: Deploy and manage connectors on Airbyte Cloud (requires 41 AIRBYTE_CLOUD_CLIENT_ID, AIRBYTE_CLOUD_CLIENT_SECRET, AIRBYTE_CLOUD_WORKSPACE_ID) 42- Local operations: Run connectors locally for data extraction (requires 43 AIRBYTE_PROJECT_DIR for artifact storage) 44 45Safety features: 46- Safe mode (default): Restricts destructive operations to objects created in 47 the current session 48- Read-only mode: Disables all write operations for cloud resources 49""".strip() 50 51set_mcp_mode() 52initialize_secrets() 53 54app: FastMCP = FastMCP("airbyte-mcp", instructions=MCP_SERVER_INSTRUCTIONS) 55"""The Airbyte MCP Server application instance.""" 56 57register_connector_registry_tools(app) 58register_local_ops_tools(app) 59register_cloud_ops_tools(app) 60register_prompts(app) 61 62 63def main() -> None: 64 """@private Main entry point for the MCP server. 65 66 This function starts the FastMCP server to handle MCP requests. 67 68 It should not be called directly; instead, consult the MCP client documentation 69 for instructions on how to connect to the server. 70 """ 71 print("Starting Airbyte MCP server.", file=sys.stderr) 72 try: 73 asyncio.run(app.run_stdio_async()) 74 except KeyboardInterrupt: 75 print("Airbyte MCP server interrupted by user.", file=sys.stderr) 76 except Exception as ex: 77 print(f"Error running Airbyte MCP server: {ex}", file=sys.stderr) 78 sys.exit(1) 79 80 print("Airbyte MCP server stopped.", file=sys.stderr) 81 82 83if __name__ == "__main__": 84 main()
MCP_SERVER_INSTRUCTIONS =
'PyAirbyte connector management and data integration server for discovering,\ndeploying, and running Airbyte connectors.\n\nUse this server for:\n- Discovering connectors from the Airbyte registry (sources and destinations)\n- Deploying sources, destinations, and connections to Airbyte Cloud\n- Running cloud syncs and monitoring sync status\n- Managing custom connector definitions in Airbyte Cloud\n- Local connector execution for data extraction without cloud deployment\n- Listing and describing environment variables for connector configuration\n\nOperational modes:\n- Cloud operations: Deploy and manage connectors on Airbyte Cloud (requires\n AIRBYTE_CLOUD_CLIENT_ID, AIRBYTE_CLOUD_CLIENT_SECRET, AIRBYTE_CLOUD_WORKSPACE_ID)\n- Local operations: Run connectors locally for data extraction (requires\n AIRBYTE_PROJECT_DIR for artifact storage)\n\nSafety features:\n- Safe mode (default): Restricts destructive operations to objects created in\n the current session\n- Read-only mode: Disables all write operations for cloud resources'
app: fastmcp.server.server.FastMCP =
FastMCP('airbyte-mcp')
The Airbyte MCP Server application instance.