Docs
Choose your preferred AI platform and authentication method to get started with Agentsfera.
TypeScript SDK
Use the MCP SDK to integrate this server into your TypeScript applications.
Installation
Install the official MCP SDKs using your package manager:
npm install @modelcontextprotocol/sdk
TypeScript SDK
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
// Create MCP client
const client = new Client({
name: "undefined",
version: "1.0.0"
})
// Connect to the MCP server
await client.connect(new StreamableHTTPClientTransport(
new URL("https://api.agentsfera.ai"),
{
requestInit: {
headers: {
"Authorization": "Bearer sk-7aefcd76-44c0-4687-a0a9-43599d050fdd",
"Content-Type": "application/json",
// Optional: Unique identifier for your user across MCP sessions
// Use the same ID to maintain session continuity across reconnects
"user-session-id": "your-user-unique-id"
}
}
}
))
// List available tools from all enabled integrations
const { tools } = await client.listTools()
console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`)
// Example: Call a tool (adjust based on your enabled integrations)
const result = await client.callTool({
name: "gmail-search-emails", // Gmail integration example
arguments: {
query: "project update",
max_results: 10
}
})
console.log("Tool result:", result)
// Tool result will contain a redirect URL to Google OAuth2 login page.
// You can customize the redirect URL to your application/agent.
// After that your application/agent will repeat the tool call.
No API keys found. Create an API key first to use the TypeScript SDK integration.