Skip to main content
Glama

Sentry MCP

Official
by getsentry
callEmbeddedAgent.ts1.46 kB
import { generateText, Output } from "ai"; import { getOpenAIModel } from "./openai-provider"; import type { z } from "zod"; export type ToolCall = { toolName: string; args: any; }; interface EmbeddedAgentResult<T> { result: T; toolCalls: ToolCall[]; } /** * Call an embedded agent with tool call capture * This is the standard way to call embedded AI agents within MCP tools * * Error handling: * - Errors are re-thrown for the calling agent to handle * - Each agent can implement its own error handling strategy */ export async function callEmbeddedAgent<T>({ system, prompt, tools, schema, }: { system: string; prompt: string; tools: Record<string, any>; schema: z.ZodSchema<T>; }): Promise<EmbeddedAgentResult<T>> { const capturedToolCalls: ToolCall[] = []; const result = await generateText({ model: getOpenAIModel("gpt-4o"), system, prompt, tools, maxSteps: 5, experimental_output: Output.object({ schema }), onStepFinish: (event) => { if (event.toolCalls && event.toolCalls.length > 0) { for (const toolCall of event.toolCalls) { capturedToolCalls.push({ toolName: toolCall.toolName, args: toolCall.args, }); } } }, }); if (!result.experimental_output) { throw new Error("Failed to generate output"); } return { result: result.experimental_output as T, toolCalls: capturedToolCalls, }; }

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/getsentry/sentry-mcp'

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