Skip to content

Commit 241cf42

Browse files
authored
Add MCP Optimizer docs (#266)
Signed-off-by: Dan Barr <6922515+danbarr@users.noreply.github.com> Co-authored-by: Dan Barr <6922515+danbarr@users.noreply.github.com>
1 parent 592d231 commit 241cf42

File tree

8 files changed

+468
-214
lines changed

8 files changed

+468
-214
lines changed

docs/toolhive/guides-cli/run-mcp-servers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ The group must exist before you can run a server in it.
185185

186186
:::
187187

188-
See [Organize servers with groups](./group-management.mdx) to learn more about
188+
See [Organize servers into groups](./group-management.mdx) to learn more about
189189
organizing servers and configuring client access.
190190

191191
### Mount a local file or directory

docs/toolhive/guides-mcp/meta-mcp.mdx

Lines changed: 0 additions & 205 deletions
This file was deleted.

docs/toolhive/guides-ui/client-configuration.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ updates the list.
1919

2020
If you organize your MCP servers into groups, you can configure client access
2121
per group. This lets you control which servers each client can access. See
22-
[Organize servers with groups](./group-management.mdx) for details.
22+
[Organize servers into groups](./group-management.mdx) for details.
2323

2424
:::
2525

@@ -82,4 +82,4 @@ for some common examples.
8282

8383
- [Client compatibility](../reference/client-compatibility.mdx)
8484
- [Run MCP servers](./run-mcp-servers.mdx)
85-
- [Organize servers with groups](./group-management.mdx)
85+
- [Organize servers into groups](./group-management.mdx)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: Optimize MCP tool usage
3+
description:
4+
Enable the MCP Optimizer to enhance tool selection and reduce token usage.
5+
---
6+
7+
## Overview
8+
9+
The ToolHive MCP Optimizer acts as an intelligent intermediary between AI
10+
clients and MCP servers. It provides tool discovery, unified access to multiple
11+
MCP servers through a single endpoint, and intelligent routing of requests to
12+
appropriate MCP tools.
13+
14+
:::info[Status]
15+
16+
The MCP Optimizer is currently experimental. If you try it out, please share
17+
your feedback on the [Stacklok Discord community](https://discord.gg/stacklok).
18+
19+
:::
20+
21+
Learn more about the MCP Optimizer, its benefits, and how it works in the
22+
tutorial:
23+
[Reduce token usage with MCP Optimizer](../tutorials/mcp-optimizer.mdx).
24+
25+
## Enable MCP Optimizer
26+
27+
:::note[Limitations]
28+
29+
MCP Optimizer does not currently work on Linux hosts or with Podman Desktop on
30+
Windows. Supported configurations:
31+
32+
- macOS with Docker Desktop, Podman Desktop, or Rancher Desktop
33+
- Windows with Docker Desktop or Rancher Desktop
34+
35+
MCP Optimizer also does not currently work with MCP servers that have network
36+
isolation enabled.
37+
38+
:::
39+
40+
To enable the MCP Optimizer in the ToolHive UI:
41+
42+
1. Open the **Settings** (⚙️) screen and enable **MCP Optimizer** under
43+
**Experimental Features**
44+
2. Click the **Configure** button on the notification that pops up, or go to the
45+
main **MCP Servers** screen and click **MCP Optimizer** in the left sidebar
46+
3. Select the group that contains the MCP servers you want to optimize and click
47+
**Apply Changes**
48+
49+
ToolHive automatically updates clients that were registered with the selected
50+
group to use the MCP Optimizer. If you want to connect a new client, go to the
51+
group which is enabled for optimization and use the **Manage Clients** button to
52+
register it.
53+
54+
For best results, connect your client to only the optimized group. If you
55+
connect it to multiple groups, ensure there is no overlap in MCP servers between
56+
the groups to avoid unpredictable behavior.
57+
58+
:::info[What's happening?]
59+
60+
When you enable MCP Optimizer, ToolHive automatically creates an internal group
61+
and runs the `mcp-optimizer` MCP server in that group.
62+
63+
The MCP Optimizer server discovers the MCP servers in the selected group and
64+
builds an index of their tools for intelligent routing. Automatic polling keeps
65+
the index up to date as servers are added or removed from the optimized group.
66+
67+
ToolHive also disconnects your AI clients from the original MCP server group and
68+
reconnects them to the MCP Optimizer group.
69+
70+
:::
71+
72+
## Customize MCP Optimizer settings
73+
74+
To update the MCP Optimizer's default settings, click the **Advanced** menu and
75+
select **Customize MCP Optimizer configuration**. This opens a form where you
76+
can modify the `mcp-optimizer` MCP server's configuration.
77+
78+
:::note
79+
80+
Changes to the MCP Optimizer configuration might cause the feature to stop
81+
working correctly. Only modify these settings if you understand their
82+
implications.
83+
84+
Generally, you should only need to change the Docker image tag and the
85+
environment variables detailed below.
86+
87+
:::
88+
89+
You can customize the MCP Optimizer's behavior using the following environment
90+
variables:
91+
92+
- `MAX_TOOLS_TO_RETURN`: Number of tools to return from `find_tool` (default:
93+
`8`)
94+
- `TOOL_DISTANCE_THRESHOLD`: Distance threshold for tool similarity (default:
95+
`1.0`)
96+
- `MAX_TOOL_RESPONSE_TOKENS`: Maximum number of tokens to return from
97+
`call_tool` (default: `None`)
98+
- `WORKLOAD_POLLING_INTERVAL`: Polling interval for running MCP servers, in
99+
seconds (default: `60`)
100+
- `REGISTRY_POLLING_INTERVAL`: Polling interval for ToolHive registry, in
101+
seconds (default: `86400`, 24 hours)
102+
103+
## Disable MCP Optimizer
104+
105+
To disable the MCP Optimizer, open the **Settings** (⚙️) screen and disable the
106+
**MCP Optimizer** option under the **Experimental Features** section.
107+
108+
ToolHive stops and removes the MCP Optimizer server and reconnects your clients
109+
to the original MCP server group.
110+
111+
## Troubleshooting
112+
113+
If you encounter issues while using the MCP Optimizer, check the logs for
114+
debugging information. On the **MCP Optimizer** page, click the **Advanced**
115+
menu and select **MCP Optimizer logs**.
116+
117+
## Related information
118+
119+
- Tutorial:
120+
[Reduce token usage with MCP Optimizer](../tutorials/mcp-optimizer.mdx)
121+
- [Organize MCP servers into groups](./group-management.mdx)

0 commit comments

Comments
 (0)