Skip to main content
Glama

mcp_openai_chat

Generate text completions using OpenAI's ChatGPT API, enabling context-aware responses for queries and conversations within the Ontology MCP server.

Instructions

OpenAI ChatGPT API를 사용하여 텍스트 완성을 생성합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_tokensNo생성할 최대 토큰 수
messagesYes대화 메시지 배열
modelYes사용할 모델 (예: gpt-4, gpt-3.5-turbo)
temperatureNo샘플링 온도(0-2)

Implementation Reference

  • The handler function for the mcp_openai_chat tool, which calls openaiService.chatCompletion and formats the response.
    async handler(args: any): Promise<ToolResponse> {
      try {
        const result = await openaiService.chatCompletion(args);
        return {
          content: [{
            type: 'text',
            text: result
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `OpenAI 채팅 오류: ${error instanceof Error ? error.message : String(error)}`
          }]
        };
      }
  • Input schema validating the parameters for the OpenAI chat completion tool.
    inputSchema: {
      type: 'object',
      properties: {
        model: {
          type: 'string',
          description: '사용할 모델 (예: gpt-4, gpt-3.5-turbo)'
        },
        messages: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              role: {
                type: 'string',
                enum: ['system', 'user', 'assistant']
              },
              content: {
                type: 'string'
              }
            },
            required: ['role', 'content']
          },
          description: '대화 메시지 배열'
        },
        temperature: {
          type: 'number',
          description: '샘플링 온도(0-2)',
          minimum: 0,
          maximum: 2
        },
        max_tokens: {
          type: 'number',
          description: '생성할 최대 토큰 수'
        }
      },
      required: ['model', 'messages']
    },
  • src/index.ts:39-39 (registration)
    Registration of mcp_openai_chat tool in MCP server capabilities.
    mcp_openai_chat: true,
  • The supporting service method that performs the actual OpenAI Chat Completions API request using axios.
    async chatCompletion(args: {
      model: string;
      messages: Array<{ role: string; content: string }>;
      temperature?: number;
      max_tokens?: number;
      stream?: boolean;
    }): Promise<string> {
      try {
        if (!OPENAI_API_KEY) {
          throw new McpError(
            ErrorCode.InternalError,
            'OPENAI_API_KEY가 설정되지 않았습니다.'
          );
        }
    
        const response = await axios.post(
          `${OPENAI_API_BASE}/chat/completions`,
          {
            model: args.model,
            messages: args.messages,
            temperature: args.temperature ?? 0.7,
            max_tokens: args.max_tokens,
            stream: args.stream ?? false
          },
          {
            headers: {
              'Content-Type': 'application/json',
              'Authorization': `Bearer ${OPENAI_API_KEY}`
            }
          }
        );
        
        return JSON.stringify(response.data, null, 2);
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const statusCode = error.response?.status;
          const responseData = error.response?.data;
          
          throw new McpError(
            ErrorCode.InternalError,
            `OpenAI API 오류 (${statusCode}): ${
              typeof responseData === 'object' 
                ? JSON.stringify(responseData, null, 2) 
                : responseData || error.message
            }`
          );
        }
        
        throw new McpError(ErrorCode.InternalError, `채팅 완성 요청 실패: ${formatError(error)}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a text generation tool but doesn't mention any behavioral traits: no information about rate limits, authentication requirements, costs, response formats, error handling, or whether this is a read-only or mutating operation. For an API call tool with zero annotation coverage, this is a significant gap in behavioral transparency.

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 a single, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized for a straightforward tool. However, it could be slightly more front-loaded by mentioning it's specifically for chat completions rather than just 'text completions,' which might be ambiguous given other OpenAI tools like embeddings or image generation.

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 this is an API call tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, how errors are handled, authentication requirements, rate limits, or costs. For a tool that interacts with an external API and has multiple parameters, more contextual information is needed to help an agent use it effectively.

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

Parameters3/5

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

The description adds no parameter information beyond what's already in the schema, which has 100% coverage. All 4 parameters (model, messages, max_tokens, temperature) are documented in the schema with descriptions. The description doesn't provide additional context about parameter usage, relationships, or examples. With complete schema coverage, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'OpenAI ChatGPT API를 사용하여 텍스트 완성을 생성합니다' (Generate text completions using the OpenAI ChatGPT API). It specifies the verb ('생성합니다' - generate), resource ('텍스트 완성' - text completions), and technology ('OpenAI ChatGPT API'). However, it doesn't differentiate from its sibling tools like mcp_gemini_chat_completion or mcp_ollama_chat_completion, which offer similar chat completion functionality through different providers.

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. It doesn't mention sibling tools like mcp_gemini_chat_completion or mcp_ollama_chat_completion, nor does it provide any context about when OpenAI's API would be preferable to other options. The description is purely functional without any comparative or contextual information.

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

Related 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/bigdata-coss/agent_mcp'

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