Skip to main content
Glama

add_knowledge_base_to_agent

Add knowledge base content to an ElevenLabs agent from files, URLs, or text to enhance its contextual understanding and response capabilities.

Instructions

Add a knowledge base to ElevenLabs workspace. Allowed types are epub, pdf, docx, txt, html.

⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.

Args:
    agent_id: ID of the agent to add the knowledge base to.
    knowledge_base_name: Name of the knowledge base.
    url: URL of the knowledge base.
    input_file_path: Path to the file to add to the knowledge base.
    text: Text to add to the knowledge base.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYes
input_file_pathNo
knowledge_base_nameYes
textNo
urlNo

Implementation Reference

  • Registration of the 'add_knowledge_base_to_agent' tool using the @mcp.tool decorator, including description and parameters.
    @mcp.tool(
        description="""Add a knowledge base to ElevenLabs workspace. Allowed types are epub, pdf, docx, txt, html.
    
        ⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.
    
        Args:
            agent_id: ID of the agent to add the knowledge base to.
            knowledge_base_name: Name of the knowledge base.
            url: URL of the knowledge base.
            input_file_path: Path to the file to add to the knowledge base.
            text: Text to add to the knowledge base.
        """
    )
  • The handler function implements the logic to create a knowledge base document via ElevenLabs API (from URL, file, or text input) and appends it to the specified agent's conversation configuration.
    def add_knowledge_base_to_agent(
        agent_id: str,
        knowledge_base_name: str,
        url: str | None = None,
        input_file_path: str | None = None,
        text: str | None = None,
    ) -> TextContent:
        provided_params = [
            param for param in [url, input_file_path, text] if param is not None
        ]
        if len(provided_params) == 0:
            make_error("Must provide either a URL, a file, or text")
        if len(provided_params) > 1:
            make_error("Must provide exactly one of: URL, file, or text")
    
        if url is not None:
            response = client.conversational_ai.knowledge_base.documents.create_from_url(
                name=knowledge_base_name,
                url=url,
            )
        else:
            if text is not None:
                text_bytes = text.encode("utf-8")
                text_io = BytesIO(text_bytes)
                text_io.name = "text.txt"
                text_io.content_type = "text/plain"
                file = text_io
            elif input_file_path is not None:
                path = handle_input_file(
                    file_path=input_file_path, audio_content_check=False
                )
                file = open(path, "rb")
    
            response = client.conversational_ai.knowledge_base.documents.create_from_file(
                name=knowledge_base_name,
                file=file,
            )
    
        agent = client.conversational_ai.agents.get(agent_id=agent_id)
    
        agent_config = agent.conversation_config.agent
        knowledge_base_list = (
            agent_config.get("prompt", {}).get("knowledge_base", []) if agent_config else []
        )
        knowledge_base_list.append(
            KnowledgeBaseLocator(
                type="file" if file else "url",
                name=knowledge_base_name,
                id=response.id,
            )
        )
    
        if agent_config and "prompt" not in agent_config:
            agent_config["prompt"] = {}
        if agent_config:
            agent_config["prompt"]["knowledge_base"] = knowledge_base_list
    
        client.conversational_ai.agents.update(
            agent_id=agent_id, conversation_config=agent.conversation_config
        )
        return TextContent(
            type="text",
            text=f"""Knowledge base created with ID: {response.id} and added to agent {agent_id} successfully.""",
        )
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the cost implication (API call that may incur costs) which is valuable behavioral context. However, it doesn't mention other important behavioral aspects like required permissions, rate limits, error conditions, or what happens on success/failure.

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 well-structured with purpose statement, allowed types, cost warning, and parameter list. It's appropriately sized for a 5-parameter tool. The cost warning is appropriately emphasized. Some redundancy exists between the purpose statement and parameter list.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter mutation tool with no annotations and no output schema, the description provides good usage guidance and cost warning but lacks details about return values, error handling, and parameter relationships. The parameter semantics are insufficient given the 0% schema coverage.

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 0%, so the description must compensate. It lists all 5 parameters in the Args section, which provides basic parameter names but minimal semantic context. It doesn't explain relationships between parameters (e.g., that url, input_file_path, and text appear to be alternative ways to provide content). Baseline would be lower, but the explicit listing of parameters raises it to 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add a knowledge base') and resource ('to ElevenLabs workspace'), and specifies allowed file types (epub, pdf, docx, txt, html). It doesn't explicitly distinguish from sibling tools, but the purpose is specific and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance with a cost warning ('⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user'), which clearly indicates when to use and when to exercise caution.

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/projectservan8n/elevenlabs-mcp'

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