Skip to main content
Glama

unichat

Engage with an AI assistant to review, evaluate, and respond to proposals or queries by submitting a system and user message for analysis.

Instructions

Chat with an assistant. Example tool use message: Ask the unichat to review and evaluate your proposal.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of exactly two messages: first a system message defining the task, then a user message with the specific query

Implementation Reference

  • Registers the 'unichat' tool with the MCP server, providing its name, description, and detailed input schema.
    @server.list_tools() async def handle_list_tools() -> list[types.Tool]: return [ types.Tool( name="unichat", description="""Chat with an assistant. Example tool use message: Ask the unichat to review and evaluate your proposal. """, inputSchema={ "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "description": "The role of the message sender. Must be either 'system' or 'user'", "enum": ["system", "user"] }, "content": { "type": "string", "description": "The content of the message. For system messages, this should define the context or task. For user messages, this should contain the specific query." }, }, "required": ["role", "content"], }, "minItems": 2, "maxItems": 2, "description": "Array of exactly two messages: first a system message defining the task, then a user message with the specific query" }, }, "required": ["messages"], }, ), ]
  • Executes the 'unichat' tool by validating the input arguments, calling the chat API with the system and user messages, formatting the response, and returning it.
    @server.call_tool() async def handle_call_tool(name: str, arguments: dict | None) -> list[types.TextContent]: if name != "unichat": logger.error(f"Unknown tool requested: {name}") raise ValueError(f"Unknown tool: {name}") try: logger.debug("Validating messages") validate_messages(arguments.get("messages", [])) response = chat_api.chat.completions.create( model=MODEL, messages=arguments["messages"], stream=False ) response = format_response(response.choices[0].message.content) return [response] except Exception as e: logger.error(f"Error calling tool: {str(e)}") raise Exception(f"An error occurred: {e}")
  • Input schema definition for the 'unichat' tool, enforcing exactly two messages: a system message followed by a user message.
    inputSchema={ "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "description": "The role of the message sender. Must be either 'system' or 'user'", "enum": ["system", "user"] }, "content": { "type": "string", "description": "The content of the message. For system messages, this should define the context or task. For user messages, this should contain the specific query." }, }, "required": ["role", "content"], }, "minItems": 2, "maxItems": 2, "description": "Array of exactly two messages: first a system message defining the task, then a user message with the specific query" }, }, "required": ["messages"], },
  • Helper function to validate the messages array for the 'unichat' tool.
    def validate_messages(messages): logger.debug(f"Validating messages: {len(messages)} messages received") if len(messages) != 2: logger.error(f"Invalid number of messages: {len(messages)}") raise ValueError("Exactly two messages are required: one system message and one user message") if messages[0]["role"] != "system": logger.error("First message has incorrect role") raise ValueError("First message must have role 'system'") if messages[1]["role"] != "user": logger.error("Second message has incorrect role") raise ValueError("Second message must have role 'user'") def format_response(response: str) -> types.TextContent:
  • Helper function to format the raw chat response into MCP TextContent format.
    def format_response(response: str) -> types.TextContent: logger.debug("Formatting response") try: formatted = {"type": "text", "text": response.strip()} logger.debug("Response formatted successfully") return formatted except Exception as e: logger.error(f"Error formatting response: {str(e)}") return {"type": "text", "text": f"Error formatting response: {str(e)}"}

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/amidabuddha/unichat-mcp-server'

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