Skip to main content
Glama

ask-openai

Query OpenAI models directly to get answers to questions, with configurable parameters for model selection, temperature, and response length.

Instructions

Ask my assistant models a direct question

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesAsk assistant
modelNogpt-4
temperatureNo
max_tokensNo

Implementation Reference

  • Registers the "ask-openai" tool with MCP server, including its description and input schema definition.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        return [
            types.Tool(
                name="ask-openai",
                description="Ask my assistant models a direct question",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "query": {"type": "string", "description": "Ask assistant"},
                        "model": {"type": "string", "default": "gpt-4", "enum": ["gpt-4", "gpt-3.5-turbo"]},
                        "temperature": {"type": "number", "default": 0.7, "minimum": 0, "maximum": 2},
                        "max_tokens": {"type": "integer", "default": 500, "minimum": 1, "maximum": 4000}
                    },
                    "required": ["query"]
                }
            )
        ]
  • Handles tool calls, specifically implementing the logic for "ask-openai" by parsing arguments and delegating to LLMConnector.ask_openai.
    @server.call_tool()
    async def handle_tool_call(name: str, arguments: dict | None) -> list[types.TextContent]:
        try:
            if not arguments:
                raise ValueError("No arguments provided")
    
            if name == "ask-openai":
                response = await connector.ask_openai(
                    query=arguments["query"],
                    model=arguments.get("model", "gpt-4"),
                    temperature=arguments.get("temperature", 0.7),
                    max_tokens=arguments.get("max_tokens", 500)
                )
                return [types.TextContent(type="text", text=f"OpenAI Response:\n{response}")]
    
            raise ValueError(f"Unknown tool: {name}")
        except Exception as e:
            logger.error(f"Tool call failed: {str(e)}")
            return [types.TextContent(type="text", text=f"Error: {str(e)}")]
  • Core implementation of the OpenAI query logic used by the "ask-openai" tool, performing the actual API call.
    async def ask_openai(self, query: str, model: str = "gpt-4", temperature: float = 0.7, max_tokens: int = 500) -> str:
        try:
            response = await self.client.chat.completions.create(
                messages=[
                    {"role": "system", "content": "You are a helpful assistant."},
                    {"role": "user", "content": query}
                ],
                model=model,
                temperature=temperature,
                max_tokens=max_tokens
            )
            return response.choices[0].message.content
        except Exception as e:
            logger.error(f"Failed to query OpenAI: {str(e)}")
            raise
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 'ask' and 'direct question,' implying a read-only query, but fails to detail authentication needs, rate limits, response format, or potential costs. This is a significant gap for an AI interaction tool with no annotation coverage.

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 with no wasted words, making it appropriately concise. However, it lacks front-loading of critical information, as it doesn't immediately clarify the tool's core function beyond a vague phrase.

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 of interacting with AI models, no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't address behavioral traits, parameter meanings, or expected outputs, leaving the agent under-informed for effective tool use.

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

Parameters2/5

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

Schema description coverage is low at 25%, with only the 'query' parameter having a minimal description ('Ask assistant'). The tool description adds no parameter semantics beyond what the schema provides, failing to compensate for the coverage gap. It doesn't explain the purpose of model selection, temperature, or max_tokens.

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 'Ask my assistant models a direct question' states a purpose (asking questions to AI models) but is vague about what 'assistant models' refers to and lacks specificity about the resource or scope. It doesn't distinguish from siblings (none exist), but the phrasing is somewhat unclear rather than tautological.

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 merely states what the tool does without context for application, leaving the agent to infer usage scenarios.

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/pierrebrunelle/mcp-server-openai'

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