Skip to main content
Glama
snilld-ai

OpenAI Assistant MCP Server

by snilld-ai

ask-openai

Ask direct questions to OpenAI's GPT models through the MCP server, receiving AI-generated answers for information, analysis, or problem-solving tasks.

Instructions

Ask my assistant models a direct question

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesAsk assistant
modelNogpt-4.1
temperatureNo
max_tokensNo

Implementation Reference

  • Core implementation of the 'ask-openai' tool: calls OpenAI's chat.completions.create API with system prompt and user query.
    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
  • Dispatch logic in the @server.call_tool() handler that invokes LLMConnector.ask_openai with arguments from the tool call.
    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}")]
  • Registration of the 'ask-openai' tool in the @server.list_tools() handler, defining name, description, and input schema.
    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.1", "enum": ["gpt-4.1", "gpt-4.1-mini", "gpt-4o", "gpt-4o-mini", "o3", "o3-mini", "o3-deep-research"]}, "temperature": {"type": "number", "default": 0.1, "minimum": 0, "maximum": 1}, "max_tokens": {"type": "integer", "default": 500, "minimum": 1, "maximum": 40000} }, "required": ["query"] } ),
  • Input schema definition for the 'ask-openai' tool, specifying parameters like query (required), model, temperature, and max_tokens.
    inputSchema={ "type": "object", "properties": { "query": {"type": "string", "description": "Ask assistant"}, "model": {"type": "string", "default": "gpt-4.1", "enum": ["gpt-4.1", "gpt-4.1-mini", "gpt-4o", "gpt-4o-mini", "o3", "o3-mini", "o3-deep-research"]}, "temperature": {"type": "number", "default": 0.1, "minimum": 0, "maximum": 1}, "max_tokens": {"type": "integer", "default": 500, "minimum": 1, "maximum": 40000} }, "required": ["query"] }

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/snilld-ai/openai-assistant-mcp'

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