Docs
Choose your preferred AI platform and authentication method to get started with Agentsfera.
Python SDK
Agentsfera Python SDK
The Agentsfera Python SDK provides a Pythonic interface for integrating MCP functionality into Python applications, AI agents, and automation scripts. Built on the official MCP Python library, it supports async/await patterns and offers seamless access to 500+ business integrations through a clean, idiomatic API.
Why Use the Python SDK?
- Async-First Design: Built for modern Python with full asyncio support for concurrent tool calls and efficient I/O operations.
- Type Hints & IDE Support: Complete type annotations for excellent autocomplete and error detection in PyCharm, VS Code, and other editors.
- StreamableHTTP Transport: Efficient HTTP-based communication with streaming support for large datasets and real-time updates.
- Easy Integration: Works seamlessly with popular frameworks like FastAPI, Flask, LangChain, and OpenAI's Python SDK.
Installation & Setup
Install via pip or uv. Authenticate with API keys in request headers, then access tools from any enabled integration using async function calls.
Installation
Install the official MCP Python SDK using your package manager:
uv add mcpPython SDK
"""
Run from the repository root:
uv run main.py
"""
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
# Connect to Agentsfera MCP server
async with streamablehttp_client(
"https://api.agentsfera.ai",
headers={
"Authorization": "Bearer sk-7aefcd76-44c0-4687-a0a9-43599d050fdd",
"Content-Type": "application/json",
"user-session-id": "your-user-unique-id"
}
) as (read_stream, write_stream, _):
# Create a session using the client streams
async with ClientSession(read_stream, write_stream) as session:
# Initialize the connection
await session.initialize()
# List available tools
tools = await session.list_tools()
print(f"Available tools: {[tool.name for tool in tools.tools]}")
if __name__ == "__main__":
asyncio.run(main())No API keys found. Create an API key first to use the Python SDK integration.
