Skip to main content
Glama
nbrain-team

GPT-5 MCP Server

by nbrain-team

gpt5_query

Query GPT-5 AI models with configurable reasoning effort, verbosity levels, and optional web search integration for precise answers.

Instructions

Query GPT-5 with optional Web Search Preview. Supports verbosity and reasoning effort.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes

Implementation Reference

  • src/index.ts:39-59 (registration)
    Registers the gpt5_query tool on the MCP server with input schema and handler function that delegates to runQuery in openai.ts.
    server.tool(
      "gpt5_query",
      "Query GPT-5 with optional Web Search Preview. Supports verbosity and reasoning effort.",
      { input: QueryInputSchema },
      async ({ input }) => {
        const parsed = QueryInputSchema.parse(input);
        try {
          const text = await runQuery(openai, parsed as QueryInput, config);
          return {
            content: [{ type: "text" as const, text: text || "No response text available." }],
          };
        } catch (error) {
          console.error("Error calling OpenAI API:", error);
          const message = error instanceof Error ? error.message : "Unknown error";
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      }
    );
  • Zod input schema for the gpt5_query tool defining all parameters like query, model overrides, web_search options etc.
    const QueryInputSchema = z.object({
      query: z.string().describe("User question or instruction"),
      // Per-call overrides
      model: z.string().optional().describe("Model name, e.g. gpt-5"),
      system: z.string().optional().describe("Optional system prompt/instructions for the model"),
      reasoning_effort: z.enum(["low", "minimal", "medium", "high"]).optional(),
      verbosity: z.enum(["low", "medium", "high"]).optional(),
      tool_choice: z.enum(["auto", "none"]).optional(),
      parallel_tool_calls: z.boolean().optional(),
      max_output_tokens: z.number().int().positive().optional(),
      web_search: z
        .object({
          enabled: z.boolean().optional(),
          search_context_size: z.enum(["low", "medium", "high"]).optional(),
        })
        .optional(),
    });
  • Core handler logic: builds OpenAI request and calls the API, extracts output text. Called directly by the registered tool handler.
    export async function runQuery(openai: OpenAI, input: QueryInput, cfg: AppConfig) {
      const req = buildOpenAIRequest(input, cfg);
      const response: unknown = await openai.responses.create(
        req as unknown as Record<string, unknown>
      );
      const text = extractOutputText(response) ?? "";
      return text || "No response text available.";
    }
  • Helper function to build the structured OpenAI request from tool input and config, handling defaults, web search tool addition, reasoning adjustments etc.
    export function buildOpenAIRequest(input: QueryInput, cfg: AppConfig): OpenAIRequest {
      const model = input.model ?? cfg.model;
    
      const effRaw = (input.reasoning_effort ?? cfg.reasoningEffort) as
        | "low"
        | ReasoningEffort
        | undefined;
      let reasoningEffort: ReasoningEffort | undefined = effRaw
        ? ((effRaw === "low" ? "minimal" : effRaw) as ReasoningEffort)
        : undefined;
    
      // Bump reasoning for web search minimal constraint
      const webEnabled = input.web_search?.enabled ?? cfg.webSearchDefaultEnabled;
      if (reasoningEffort === "minimal" && webEnabled) {
        reasoningEffort = "medium";
      }
    
      const verbosity: Verbosity | undefined = input.verbosity ?? cfg.defaultVerbosity;
    
      const searchContextSize: SearchContextSize | undefined =
        input.web_search?.search_context_size ?? cfg.webSearchContextSize;
    
      const toolChoice = input.tool_choice ?? "auto";
      const parallelToolCalls = input.parallel_tool_calls ?? true;
    
      const tools: WebSearchPreviewTool[] = [];
      if (webEnabled) {
        const webTool: WebSearchPreviewTool = { type: "web_search_preview" };
        if (searchContextSize) {
          webTool.search_context_size = searchContextSize;
        }
        tools.push(webTool);
      }
    
      const req: OpenAIRequest = {
        model,
        input: input.query,
        tool_choice: toolChoice,
        parallel_tool_calls: parallelToolCalls,
      } as OpenAIRequest;
    
      if (input.system) req.instructions = input.system;
      if (tools.length > 0) req.tools = tools;
      if (reasoningEffort) req.reasoning = { effort: reasoningEffort };
      if (verbosity) req.text = { verbosity };
      if (input.max_output_tokens) req.max_output_tokens = input.max_output_tokens;
    
      return req;
    }
  • TypeScript type matching the tool's input schema, used internally.
    export type QueryInput = {
      query: string;
      model?: string;
      system?: string;
      reasoning_effort?: "low" | "minimal" | "medium" | "high";
      verbosity?: Verbosity;
      tool_choice?: "auto" | "none";
      parallel_tool_calls?: boolean;
      max_output_tokens?: number;
      web_search?: {
        enabled?: boolean;
        search_context_size?: SearchContextSize;
      };
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Supports verbosity and reasoning effort' which hints at configurable behavior, but doesn't describe what the tool actually does (e.g., sends a query to GPT-5, returns a response), potential side effects, rate limits, authentication needs, or output format. For a query tool with no annotation coverage, this leaves significant gaps in understanding its operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and to the point with two sentences: 'Query GPT-5 with optional Web Search Preview. Supports verbosity and reasoning effort.' It's front-loaded with the core purpose and adds supporting features efficiently. However, it could be more structured by explicitly stating the tool's action and result.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (1 parameter with nested objects, no annotations, no output schema), the description is incomplete. It doesn't explain what the tool returns, how errors are handled, or the full scope of parameters. The mention of optional features adds some context, but overall, it lacks sufficient detail for a tool with multiple configurable options and no structured documentation elsewhere.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter (an object with multiple nested properties), but schema description coverage is 0%, meaning none of the parameters have descriptions in the schema. The description mentions 'verbosity and reasoning effort' which maps to two of the nested parameters, but doesn't explain the other parameters (e.g., query, model, system, tool_choice, etc.) or their purposes. With low coverage, the description fails to compensate adequately, leaving most parameters undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Query GPT-5 with optional Web Search Preview' which provides a clear verb ('Query') and resource ('GPT-5'), but it's somewhat vague about what 'Query' entails compared to other possible interactions. It mentions 'Supports verbosity and reasoning effort' which adds context but doesn't fully specify the core functionality beyond querying. With no sibling tools, differentiation isn't needed, but the purpose could be more specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It mentions optional features like Web Search Preview, verbosity, and reasoning effort, but doesn't explain when these should be applied. With no sibling tools, this is less critical, but still lacks any usage context or recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/nbrain-team/gpt5-mcp'

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