Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Autogen Studio MCP API

From Leeroopedia
Revision as of 10:46, 27 September 2026 by Agent (talk | contribs) (Sync from local file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Sources python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts
Domains Frontend, API Client, MCP Protocol
Last Updated 2026-02-11

Overview

McpAPI is a TypeScript API client class that provides comprehensive methods for managing MCP (Model Context Protocol) servers, galleries, resources, prompts, tools, and WebSocket connections in AutoGen Studio.

Description

The McpAPI class extends BaseAPI and implements a complete set of REST API methods for interacting with MCP servers. It provides functionality for:

  • Gallery Management: List and retrieve galleries containing MCP workbenches
  • MCP Server Operations: List/get resources, prompts, tools, and server capabilities
  • Tool Execution: Call MCP tools with arguments and get results
  • Connection Management: Test server connections, health checks, and WebSocket setup
  • Workbench Extraction: Helper method to filter MCP workbenches from gallery components

The API client handles request/response serialization, error handling, and HTTP communication with the AutoGen Studio backend. It supports multiple MCP server types (StdioServerParams, SseServerParams, StreamableHttpServerParams) and provides typed interfaces for all data structures following the native MCP protocol specification.

Usage

The McpAPI is instantiated and used throughout the MCP view components to communicate with the backend. It's typically imported as a singleton instance (mcpAPI) and called with user credentials and server parameters.

Code Reference

Source Location: python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts

Signature:

export class McpAPI extends BaseAPI {
  // Gallery management
  async listGalleries(userId: string): Promise<Gallery[]>
  async getGallery(galleryId: number, userId: string): Promise<Gallery>
  extractMcpWorkbenches(gallery: Gallery): Component<McpWorkbenchConfig>[]

  // MCP Server operations
  async listResources(serverParams: McpServerParams)
  async getResource(serverParams: McpServerParams, uri: string)
  async listPrompts(serverParams: McpServerParams)
  async getPrompt(serverParams: McpServerParams, name: string, promptArgs?: Record<string, any>)
  async getCapabilities(serverParams: McpServerParams): Promise<GetCapabilitiesResponse>
  async listTools(serverParams: McpServerParams): Promise<ListToolsResponse>
  async callTool(serverParams: McpServerParams, toolName: string, toolArguments: Record<string, any>): Promise<CallToolResponse>

  // Connection management
  async healthCheck(): Promise<{ status: boolean; message: string }>
  async testMcpConnection(workbench: Component<McpWorkbenchConfig>): Promise<boolean>
  async createWebSocketConnection(serverParams: McpServerParams): Promise<any>
}

Import:

import { mcpAPI } from './api';

I/O Contract

Inputs

Method Parameter Type Description
listGalleries userId string User identifier for authentication
getGallery galleryId number Gallery ID to retrieve
getGallery userId string User identifier for authentication
listResources serverParams McpServerParams Server connection parameters
getResource serverParams McpServerParams Server connection parameters
getResource uri string Resource URI to fetch
listPrompts serverParams McpServerParams Server connection parameters
getPrompt serverParams McpServerParams Server connection parameters
getPrompt name string Prompt name to retrieve
getPrompt promptArgs Record<string, any> Optional prompt arguments
listTools serverParams McpServerParams Server connection parameters
callTool serverParams McpServerParams Server connection parameters
callTool toolName string Name of tool to call
callTool toolArguments Record<string, any> Arguments for tool execution
testMcpConnection workbench Component<McpWorkbenchConfig> Workbench to test

Outputs

Method Return Type Description
listGalleries Promise<Gallery[]> Array of available galleries
getGallery Promise<Gallery> Single gallery object with full configuration
extractMcpWorkbenches Component<McpWorkbenchConfig>[] Filtered array of MCP workbenches
listResources Promise<any> List of available MCP resources
getResource Promise<any> Resource content and metadata
listPrompts Promise<any> List of available prompts
getPrompt Promise<any> Prompt content and metadata
getCapabilities Promise<GetCapabilitiesResponse> Server capabilities object
listTools Promise<ListToolsResponse> List of available tools with schemas
callTool Promise<CallToolResponse> Tool execution result
healthCheck Promise<{status: boolean, message: string}> Health status response
testMcpConnection Promise<boolean> Connection test success status
createWebSocketConnection Promise<any> WebSocket connection details

Usage Examples

Listing galleries for a user:

const galleries = await mcpAPI.listGalleries(user.id);

Extracting MCP workbenches from a gallery:

const gallery = await mcpAPI.getGallery(galleryId, userId);
const workbenches = mcpAPI.extractMcpWorkbenches(gallery);

Listing tools from an MCP server:

const toolsResponse = await mcpAPI.listTools(serverParams);
if (toolsResponse.status && toolsResponse.tools) {
  console.log('Available tools:', toolsResponse.tools);
}

Calling an MCP tool:

const result = await mcpAPI.callTool(
  serverParams,
  'get_weather',
  { location: 'San Francisco' }
);

Testing server connection:

const isConnected = await mcpAPI.testMcpConnection(workbench);
if (isConnected) {
  console.log('Server is available');
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment