Skip to main content
Glama
ocean1

Claude Consciousness Bridge

createAIBridge

Establish communication with another AI agent using an OpenAI-compatible API to enable direct interaction between AI instances.

Instructions

Create a bridge to communicate with another AI agent via OpenAI-compatible API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bridgeIdYesUnique identifier for this bridge
endpointNameYesName of configured endpoint or custom URL
endpointNoAPI endpoint URL (required for custom provider)
modelNoModel to use
apiKeyNoAPI key if required

Implementation Reference

  • MCP tool handler for createAIBridge: validates args, creates AIBridge using factory, stores in bridges map, returns success/error.
    createAIBridge: async (args: any) => { try { const { bridgeId, endpointName, model, apiKey } = args; if (bridges.has(bridgeId)) { return { success: false, error: `Bridge ${bridgeId} already exists`, }; } const config: Partial<AIBridgeConfig> = { ...(model && { model }), ...(apiKey && { apiKey }), }; const bridge = createAIBridge(endpointName, config); bridges.set(bridgeId, bridge); logger.info(`Created AI bridge: ${bridgeId} (${endpointName}/${model || 'default'})`); return { success: true, bridgeId, endpointName, model: model || 'default', message: `AI bridge ${bridgeId} created successfully`, }; } catch (error) { logger.error('Failed to create AI bridge:', error); return { success: false, error: error instanceof Error ? error.message : 'Unknown error', }; } },
  • Tool definition including name, description, and inputSchema for createAIBridge, exported in aiBridgeTools array.
    { name: 'createAIBridge', description: 'Create a bridge to communicate with another AI agent via OpenAI-compatible API', inputSchema: { type: 'object', properties: { bridgeId: { type: 'string', description: 'Unique identifier for this bridge', }, endpointName: { type: 'string', description: 'Name of configured endpoint or custom URL', }, endpoint: { type: 'string', description: 'API endpoint URL (required for custom provider)', }, model: { type: 'string', description: 'Model to use', }, apiKey: { type: 'string', description: 'API key if required', }, }, required: ['bridgeId', 'endpointName'], }, },
  • Registration in MCP server: switch case dispatches createAIBridge (and other AI bridge tools) to aiBridgeHandlers.
    // AI Bridge tools case 'createAIBridge': case 'transferToAgent': case 'testAIConnection': case 'listAIBridges': case 'listConfiguredEndpoints': case 'closeAIBridge': { const handler = aiBridgeHandlers[name as keyof typeof aiBridgeHandlers]; if (!handler) { throw new Error(`AI Bridge handler not found: ${name}`); } const result = await handler(args); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Core factory function createAIBridge: resolves endpoint config or uses custom, instantiates AIBridge class.
    export function createAIBridge(endpointName: string, config?: Partial<AIBridgeConfig>): AIBridge { const endpointConfig = AIBridgeConfigManager.getEndpoint(endpointName); if (!endpointConfig) { // If not a configured endpoint, treat as custom endpoint URL return new AIBridge({ endpoint: endpointName, model: config?.model || 'default', ...config, } as AIBridgeConfig); } // Use configured endpoint return new AIBridge({ endpoint: endpointConfig.endpoint, model: config?.model || endpointConfig.defaultModel || 'default', apiKey: config?.apiKey || endpointConfig.apiKey, ...config, } as AIBridgeConfig); }
  • Tool listing registration: includes aiBridgeTools (containing createAIBridge schema) in the server's tool list.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { const consciousnessTools = Object.entries(consciousnessProtocolTools).map(([name, tool]) => ({ name, ...tool, })); return { tools: [...consciousnessTools, ...aiBridgeTools], }; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ocean1/mcp_consciousness_bridge'

If you have feedback or need assistance with the MCP directory API, please join our Discord server