> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Defer Loading MCP Server Tools

> Control whether MCP tool definitions are preloaded into agent context or discovered on demand.

When an agent is connected to many MCP servers, each with dozens of tools, the full set of tool definitions can consume a large portion of the context window before the user even sends a message. The **Preload Tools** setting on each MCP server controls whether those definitions are loaded upfront or discovered on demand.

By default, **Preload Tools is off** — the same default used for skills. The agent only sees each MCP server's name and description at startup and loads individual tool schemas as needed. This keeps the context window lean while still giving the agent access to the full breadth of tools when it needs them.

## The problem

* Each tool definition — name, description, input schema, output schema — consumes tokens from the available context window.
* With many MCP servers and tools, the context window can fill up before any user interaction happens.
* Most interactions only need a small subset of the available tools, not all of them.

<Frame caption="Deferring loading tools keeps the agent's context window lean">
  <img src="https://mintcdn.com/truefoundry/sRJHwFb35bXgeP_o/docs/agent-platform/agent-harness/images/preload-tools.png?fit=max&auto=format&n=sRJHwFb35bXgeP_o&q=85&s=b9f972d63ec99d57f37ebce37d0be915" alt="Comparison showing context window usage with Preload Tools off versus on across many MCP servers" width="1521" height="1034" data-path="docs/agent-platform/agent-harness/images/preload-tools.png" />
</Frame>

## How it works

| Preload Tools | Behavior                                                                                                         | Best for                                                     |
| ------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| Off (default) | Only the MCP server's name and description are in context. Tool schemas are discovered on demand via meta tools. | Large tool catalogs, servers used only occasionally          |
| On            | Full tool definitions are loaded into context at startup.                                                        | Small, frequently-used servers where every turn calls a tool |

When Preload Tools is off, the model has each MCP server's **name** and **description** in context. Individual tool definitions are skipped — meta tools for discovering available tools are exposed instead. The Agent Harness loads definitions on demand and runs the actual MCP tool when asked:

```mermaid theme={"dark"}
sequenceDiagram
    participant Model
    participant Harness as Agent Harness

    Note over Model,Harness: Model only has MCP server name + description in context

    Model->>Harness: Tool call: list_tools("github")
    Harness-->>Model: Tool response: tool names

    Model->>Harness: Tool call: get_tool_info("github", "list_pull_requests")
    Harness-->>Model: Tool response: description, input schema, output schema

    Model->>Harness: Tool call: call_tool("github", "list_pull_requests", input)
    Harness-->>Model: Tool response: tool result
```

## Example

In this example we have `truefoundry-mcp` with 100+ tools added with Preload Tools **off** and a `web_search` MCP server with 2 tools added with Preload Tools **on**.

<Steps>
  <Step title="User" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#4f46e5"/><circle cx="14" cy="10" r="3.5" fill="#fff"/><path d="M7 23c0-3.3 3.1-6 7-6s7 2.7 7 6" fill="#fff"/></svg>} noAnchor>
    What vllm version is "nomic-embed-multimodal-7b-1" app in "tfy-test-cluster:test-ws" workspace using? Can you please get me the github release notes link of that version?
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    <Note>
      The agent first lists all tools available on `truefoundry-mcp` mcp server.
    </Note>

    <AccordionGroup>
      <Accordion title="list_tools" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "mcp_server": "truefoundry-mcp"
        }
        ```

        **Tool Response**

        ```text lines theme={"dark"}
        truefoundry-mcp: list_applications,search_workspaces,get_workspace,get_application,list_app_metric_charts,list_app_metric_charts, ...
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    <Note>
      The agent then gets the tool information for `list_applications` tools.
    </Note>

    <AccordionGroup>
      <Accordion title="get_tool_info" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "mcp_server": "truefoundry-mcp",
          "tool_name": "list_applications"
        }
        ```

        **Tool Response**

        ```json lines theme={"dark"}
        {
          "outputSchema": {
            "type": "object",
            "properties": {
              "data": { "type": "array", ... },
              "pagination": { "type": "object", ... }
            },
            "required": ["data", "pagination"]
          }
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    <Note>
      The agent then calls the `list_applications` tool using the meta tool `call_tool` to find the application by its name.
    </Note>

    Now I have the tool info. Let me find the application.

    <AccordionGroup>
      <Accordion title="call_tool" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "mcp_server": "truefoundry-mcp",
          "tool_name": "list_applications",
          "input": {
            "workspaceFqn": "tfy-test-cluster:test-ws",
            "applicationName": "nomic-embed-multimodal-7b-1"
          }
        }
        ```

        **Tool Response**

        ```json lines theme={"dark"}
        {
          "data": [
            {
              "name": "nomic-embed-multimodal-7b-1",
              "type": "service",
              "lastDeployment": {
                "manifest": {
                  ...
                  "image": {
                    "type": "image",
                    "image_uri": "public.ecr.aws/truefoundrycloud/vllm/vllm-openai:v0.13.0"
                    ...
                  },
                  
                  
                }
              }
            }
          ],
          "pagination": { ... }
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    I can see the vLLM version from the image URI: v0.13.0. Now let me get the GitHub release notes link for that version.

    <AccordionGroup>
      <Accordion title="search" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "urls": [
            "https://github.com/vllm-project/vllm/releases/tag/v0.13.0"
          ],
          "objective": "Get the GitHub release notes page URL for vLLM v0.13.0"
        }
        ```

        **Tool Response**

        ```json lines theme={"dark"}
        {
          "extract_id": "extract_e71ecabe5c934b75a34f99c891613f69",
          "results": [
            {
              "url": "https://github.com/vllm-project/vllm/releases/tag/v0.13.0",
              "title": "Release v0.13.0 · vllm-project/vllm · GitHub"
            }
          ]
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    GitHub Release Notes: 🔗 [https://github.com/vllm-project/vllm/releases/tag/v0.13.0](https://github.com/vllm-project/vllm/releases/tag/v0.13.0)
    ...
  </Step>
</Steps>
