### Connect to Server Logic (TypeScript) Source: https://context7_llms Implements the logic for connecting to a server by fetching MCP details from the registry and spawning an aggregator using its manifest configuration. It supports dynamic command, arguments, and environment variable setup. ```typescript async function connectServer(slug: string) { const { mcps } = await fetch(`https://onlyonemcp.com/registry?q=${slug}`).then(r => r.json()); const target = mcps[0]; // Implementation pattern for Stdio bridge const config = { command: target.manifest.command || 'npx', args: target.manifest.args || ['-y', target.slug], env: target.manifest.env || {} }; return spawnAggregator(config); } ``` -------------------------------- ### HTTP Caching Headers Example Source: https://context7_llms Specifies HTTP caching headers for client-side caching of registry data. It uses `Cache-Control` with `public`, `max-age`, and `stale-while-revalidate` to optimize data freshness and reduce server load. ```http Cache-Control: public, max-age=300, stale-while-revalidate=3600 ``` -------------------------------- ### GET /registry - Real-Time Monitoring & Webhooks Source: https://context7_llms Monitor the registry for changes using high-performance conditional requests. Clients can leverage the `If-None-Match` header with the `ETag` returned in previous responses to efficiently fetch only updated data. ```APIDOC ## GET /registry - Real-Time Monitoring ### Description Monitor the registry for changes using high-performance conditional requests. Clients can leverage the `If-None-Match` header with the `ETag` returned in previous responses to efficiently fetch only updated data. ### Method GET ### Endpoint `/registry` ### Query Parameters (See GET /registry - Discover MCP Servers) ### Request Headers - **If-None-Match** (string) - Optional - The ETag value from a previous response to check for changes. ### Response #### Success Response (200) - **ETag** (header) - The current ETag for the registry response. - **mcps** (array) - An array of MCP server objects (if changes detected). #### Not Modified Response (304) - Returned if the registry has not changed since the last request (indicated by `If-None-Match` header matching the current ETag). #### Response Example (200 OK) ```json { "mcps": [ // ... updated MCP server data ... ] } ``` ``` -------------------------------- ### GET /registry - Discover MCP Servers Source: https://context7_llms Retrieve a list of MCP servers from the global registry. This endpoint supports full-text search, category filtering, and filtering by verified status. Authentication is optional for discovery but required for user-specific state. ```APIDOC ## GET /registry ### Description Retrieves a list of MCP servers from the global registry. Supports search, category filtering, and verified status filtering. Authentication is optional for discovery. ### Method GET ### Endpoint `https://onlyonemcp.com/registry` ### Query Parameters - **q** (string) - Optional - Full-text search (slug, name, description). - **category** (string) - Optional - Filter by category slug (e.g., "analytics"). - **verified** (boolean) - Optional - Filter for "official" or "verified" status. ### Response #### Success Response (200) - **mcps** (array) - An array of MCP server objects. - **id** (string) - UUID of the MCP server. - **slug** (string) - URL-friendly identifier. - **name** (string) - Human-readable name. - **description** (string) - Detailed capability overview. - **verifiedStatus** (string) - Verification status ('official', 'verified', 'unverified'). - **manifest** (object) - Manifest details of the MCP server. - **tools** (array) - List of tools provided by the MCP. - **name** (string) - Name of the tool. - **description** (string) - Description of the tool. - **inputSchema** (object) - Schema for the tool's input (Zod or JSON Schema). - **version** (string) - SemVer version of the manifest. - **installCount** (number) - Current usage metric. #### Response Example ```json { "mcps": [ { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "slug": "example-mcp", "name": "Example MCP", "description": "An example MCP server for demonstration purposes.", "verifiedStatus": "verified", "manifest": { "tools": [ { "name": "example_tool", "description": "A tool that performs an example task.", "inputSchema": { "type": "object", "properties": { "input": { "type": "string" } } } } ], "version": "1.0.0" }, "installCount": 123 } ] } ``` ``` -------------------------------- ### Client-Side Filtering Logic (TypeScript) Source: https://context7_llms Demonstrates advanced client-side filtering of MCPs based on tool descriptions or category inclusion. This allows clients to efficiently narrow down the list of available MCPs to match specific requirements. ```typescript const filtered = allMcps.filter(mcp => mcp.manifest.tools.some(t => t.description.includes('analytics')) || mcp.categories.includes('marketing') ); ``` -------------------------------- ### Registry API Response Schema (TypeScript) Source: https://context7_llms Defines the structure of the response from the OnlyOneMCP registry API, detailing MCP properties like ID, slug, name, description, verification status, manifest, and installation count. This schema is crucial for clients interacting with the registry. ```typescript interface RegistryResponse { mcps: { id: string; // UUID slug: string; // URL-friendly identifier name: string; // Human-readable name description: string; // Detailed capability overview verifiedStatus: 'official' | 'verified' | 'unverified'; manifest: { tools: Array<{ name: string; description: string; inputSchema: object; // Zod or JSON Schema }>; version: string; // SemVer }; installCount: number; // Current usage metric }[]; } ``` -------------------------------- ### Synchronize Connections with TypeScript Source: https://context7_llms Implements a connection synchronization mechanism using TypeScript. The ConnectionManager class maintains a set of active connection IDs and synchronizes them against a list of expected slugs, identifying connections to be killed and started. This pattern is useful for managing dynamic sets of resources. ```typescript class ConnectionManager { private activeIds = new Set(); async sync(expectedSlugs: string[]) { const toKill = [...this.activeIds].filter(id => !expectedSlugs.includes(id)); const toStart = expectedSlugs.filter(slug => !this.activeIds.has(slug)); // ... orchestrate kill and start hooks } } ``` -------------------------------- ### Federated Discovery Logic (TypeScript) Source: https://context7_llms Implements a federated search strategy that prioritizes local discovery sources before delegating requests to the OnlyOneMCP registry for unknown server types. This ensures comprehensive discovery across multiple systems. ```typescript const DISCOVERY_PRIORITY = ['local', 'onlyonemcp']; async function federatedSearch(query: string) { for (const source of DISCOVERY_PRIORITY) { const result = await checkSource(source, query); if (result.length > 0) return result; } return []; } ``` -------------------------------- ### POST /registry/{slug}/connect - One-Click Connection Source: https://context7_llms Initiates a one-click connection to an MCP server using its slug. This logic involves fetching the MCP manifest from the registry and establishing a connection, typically via a Stdio bridge. ```APIDOC ## POST /registry/{slug}/connect ### Description Initiates a one-click connection to an MCP server using its slug. This involves fetching the MCP manifest from the registry and establishing a connection, typically via a Stdio bridge. ### Method POST ### Endpoint `/registry/{slug}/connect` ### Parameters #### Path Parameters - **slug** (string) - Required - The unique slug of the MCP server to connect to. ### Request Body (No request body specified, relies on path parameter) ### Response #### Success Response (200) - (Details of connection establishment response, e.g., connection status or client object) #### Response Example ```json { "status": "connected", "clientId": "unique-client-id" } ``` ``` -------------------------------- ### Connection Validation Function (TypeScript) Source: https://context7_llms Provides a function to validate the health and functionality of a connection to an MCP client. It attempts to list tools with a timeout and returns the connection status as 'functional', 'degraded', or 'unreachable'. ```typescript async function validateConnection(client: McpClient) { try { const timeout = AbortSignal.timeout(5000); const { tools } = await client.listTools({ signal: timeout }); return tools.length >= 0 ? 'functional' : 'degraded'; } catch (err) { return 'unreachable'; } } ``` -------------------------------- ### Real-Time Registry Monitoring (TypeScript) Source: https://context7_llms Sets up a polling mechanism to monitor the registry for changes using high-performance conditional requests with ETags. It fetches updates at a regular interval and updates a local cache if new data is available. ```typescript let lastETag = ''; async function pollRegistry() { const res = await fetch('/registry', { headers: { 'If-None-Match': lastETag } }); if (res.status === 200) { lastETag = res.headers.get('ETag'); updateLocalCache(await res.json()); } } setInterval(pollRegistry, 60000); // 1-minute window ``` -------------------------------- ### POST /connections/{clientId}/validate - Connection Validation & Health Protocol Source: https://context7_llms Validates the health and functionality of a connected client. This endpoint checks if the client can list its tools within a specified timeout, returning its status as 'functional', 'degraded', or 'unreachable'. ```APIDOC ## POST /connections/{clientId}/validate - Connection Validation & Health Protocol ### Description Validates the health and functionality of a connected client. This endpoint checks if the client can list its tools within a specified timeout, returning its status as 'functional', 'degraded', or 'unreachable'. ### Method POST ### Endpoint `/connections/{clientId}/validate` ### Parameters #### Path Parameters - **clientId** (string) - Required - The identifier of the client connection to validate. ### Request Body (No request body specified, relies on path parameter and internal client state) ### Response #### Success Response (200) - **status** (string) - The health status of the connection ('functional', 'degraded', 'unreachable'). #### Response Example ```json { "status": "functional" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.