Skip to main content
Glama

unichat

Chat with an AI assistant to review documents, evaluate proposals, or answer questions by providing a system message and user query.

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

  • The handler function for the 'unichat' tool. It validates the tool name, checks the messages input, calls the UnifiedChatApi to generate a response using the specified model, formats the response, and returns it as TextContent.
    @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}")
  • The JSON schema defining the input structure for the 'unichat' tool, requiring an object with a 'messages' array of exactly two items (system and user roles).
    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"],
    },
  • The list_tools handler that registers and exposes the 'unichat' tool, including its name, description, and 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"],
                },
            ),
        ]
  • Helper function to validate the messages input for the unichat tool, ensuring exactly two messages with correct roles.
    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'")
  • Helper function to format the chat API response into the required TextContent type.
    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)}"}
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions nothing about behavioral traits like whether this is a read-only operation, if it requires authentication, rate limits, or what kind of responses to expect. The example hints at evaluation tasks but doesn't disclose operational characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief but includes an example that adds some value. However, the formatting with extra whitespace is awkward, and the example could be integrated more cleanly. It's not excessively verbose, but the structure could be improved for better front-loading of information.

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 chat tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the assistant does, what domains it covers, what format responses take, or any limitations. The example provides minimal context but doesn't compensate for the lack of structured information about this interactive tool.

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?

Schema description coverage is 100%, so the schema fully documents the single parameter (messages array with exactly two messages). The description adds no parameter information beyond what's in the schema, not even mentioning the two-message requirement. Baseline 3 is appropriate when schema does all the work.

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 states 'Chat with an assistant' which indicates the basic function, but it's vague about what this assistant does or what domain it operates in. The example tool use message adds some context about reviewing proposals, but doesn't make the purpose specific or distinguish it from other chat tools. It's not tautological but lacks clear differentiation.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The example suggests it can be used for reviewing proposals, but there's no mention of prerequisites, limitations, or when not to use it. With no sibling tools, the bar is lower, but still lacks basic usage context.

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

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