Skip to main content
Glama
pyroprompts

any-chat-completions-mcp

by pyroprompts

chat-with-openai

Interact with OpenAI's chat completions to process and generate text responses using the Any Chat Completions MCP server for streamlined integration.

Instructions

Text chat with OpenAI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content of the chat to send to OpenAI

Implementation Reference

  • Executes the 'chat-with-openai' tool by creating an OpenAI client with configured env vars, sending a chat completion request with optional system prompt, and returning the AI response or error.
    case `chat-with-${AI_CHAT_NAME_CLEAN}`: {
      const content = String(request.params.arguments?.content)
      if (!content) {
        throw new Error("Content is required")
      }
    
      const client = new OpenAI({
        apiKey: AI_CHAT_KEY,
        baseURL: AI_CHAT_BASE_URL,
        timeout: parseInt(`${AI_CHAT_TIMEOUT}`, 10),
      });
    
      try {
        const messages: [OpenAI.ChatCompletionMessageParam]  = [
          { role: 'user', content: content }
        ];
        if (AI_CHAT_SYSTEM_PROMPT) {
          messages.unshift({ role: 'system', content: `${AI_CHAT_SYSTEM_PROMPT}` });
        }
        messages.push();
        const chatCompletion = await client.chat.completions.create({
          messages, 
          model: AI_CHAT_MODEL.trim(), // Trim to remove any whitespace
        });
    
        const responseContent = chatCompletion.choices[0]?.message?.content;
        
        if (!responseContent) {
          throw new Error('No response content received from API');
        }
    
        return {
          content: [
            {
              type: "text",
              text: responseContent
            }
          ]
        };
      } catch (error: any) {
        const errorMessage = error.response?.data?.error?.message || error.message || 'Unknown error occurred';
        console.error('Chat completion error:', errorMessage);
        
        return {
          content: [
            {
              type: "text",
              text: `Error: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:78-97 (registration)
    Registers the 'chat-with-openai' tool (dynamically named via AI_CHAT_NAME_CLEAN) in the list of available tools, including its description and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: `chat-with-${AI_CHAT_NAME_CLEAN}`,
            description: `Text chat with ${AI_CHAT_NAME}`,
            inputSchema: {
              type: "object",
              properties: {
                content: {
                  type: "string",
                  description: `The content of the chat to send to ${AI_CHAT_NAME}`,
                }
              },
              required: ["content"]
            }
          }
        ]
      };
    });
  • Defines the input schema for the 'chat-with-openai' tool, requiring a 'content' string.
    inputSchema: {
      type: "object",
      properties: {
        content: {
          type: "string",
          description: `The content of the chat to send to ${AI_CHAT_NAME}`,
        }
      },
      required: ["content"]
    }
  • Helper that computes the clean lowercase hyphenated name for the chat tool, e.g., 'openai' from 'OpenAI', used to form 'chat-with-openai'.
    const AI_CHAT_NAME_CLEAN = AI_CHAT_NAME.toLowerCase().replace(' ', '-')
Behavior1/5

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

The description provides no behavioral information beyond the basic action. There are no annotations to cover safety, rate limits, authentication needs, or response behavior. The description doesn't mention whether this is a read-only operation, what models are used, whether it maintains conversation state, or any other behavioral characteristics.

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 extremely concise at just three words, which is appropriate for a simple tool. However, this conciseness comes at the cost of being under-specified rather than efficiently informative. It's front-loaded but lacks substance.

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?

For a tool that interacts with an external AI service, the description is severely incomplete. With no annotations, no output schema, and a minimal description, it fails to provide necessary context about authentication, rate limits, model selection, response format, or error handling. The agent would have significant gaps in understanding how to use this tool 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?

With 100% schema description coverage for the single parameter, the schema already fully documents the 'content' parameter. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline of 3 for high schema coverage without adding value.

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 'Text chat with OpenAI' states the basic action (chat) and target (OpenAI), but it's vague about what this actually does. It doesn't specify whether this is a completion, conversation, or specific model interaction, and with no sibling tools for comparison, it's unclear if this is the only way to interact with OpenAI or what distinguishes it.

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?

There's no guidance on when to use this tool versus alternatives. The description doesn't mention any prerequisites, context for usage, or limitations. With no sibling tools listed, there's no explicit comparison, but the description fails to provide any usage context whatsoever.

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/pyroprompts/any-chat-completions-mcp'

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