@@ -5,7 +5,7 @@ description:
55 Using the Context7 MCP server with ToolHive for up-to-date documentation.
66last_update :
77 author : danbarr
8- date : 2025-08-27
8+ date : 2025-10-08
99---
1010
1111## Overview
@@ -39,25 +39,21 @@ While Context7 works without an API key, registering at
3939- Priority access during peak usage
4040- Better performance for frequent queries
4141
42- :::note
42+ <Tabs groupId = ' mode' queryString = ' mode' >
43+ <TabItem value = ' ui' label = ' UI' default >
4344
44- Currently, the Context7 MCP server only supports a CLI argument for the API key.
45- This means ToolHive's secrets management cannot be used to inject the key as an
46- environment variable. Instead, you must pass the API key directly as a
47- command-line argument when starting the server.
45+ ** Remote MCP server**
4846
49- :::
47+ Select the ` context7-remote ` MCP server in the ToolHive registry. Currently,
48+ ToolHive doesn't support adding custom headers for remote MCP servers, so using
49+ the remote server is limited to basic usage without an API key.
5050
51- <Tabs groupId = ' mode' queryString = ' mode' >
52- <TabItem value = ' ui' label = ' UI' default >
51+ ** Local MCP server**
5352
54- Select the ` context7 ` MCP server in the ToolHive registry. The server works
55- without authentication for basic usage, but you can add an API key for higher
56- rate limits.
53+ Select the ` context7 ` MCP server in the ToolHive registry.
5754
58- In the ** Command arguments** section, optionally add ` --api-key YOUR_API_KEY ` if
59- you have a Context7 API key. This provides higher rate limits and priority
60- access.
55+ The server works without authentication for basic usage, but you can optionally
56+ add an API key in the ** Secrets** section for higher rate limits.
6157
6258:::tip[ Security tip]
6359
@@ -69,19 +65,18 @@ the server's network access using the default profile contained in the registry.
6965</TabItem >
7066<TabItem value = ' cli' label = ' CLI' >
7167
72- Run with the default configuration (no API key required for basic usage):
68+ For basic (unauthenticated) usage, you can connect directly to Context7's public
69+ MCP server:
7370
7471``` bash
75- thv run context7
72+ thv run context7-remote
7673```
7774
78- If you have a Context7 API key for higher rate limits, you can pass it directly
79- as a command-line argument. You can store the key in a ToolHive secret and
80- retrieve it when starting the server:
75+ Alternatively, run the local containerized MCP server with the default
76+ configuration (no API key required for basic usage):
8177
8278``` bash
83- thv secret set context7
84- thv run context7 -- --api-key $( thv secret get context7)
79+ thv run context7
8580```
8681
8782Enable [ network isolation] ( ../guides-cli/network-isolation.mdx ) using the
@@ -91,10 +86,18 @@ default profile from the registry to restrict the server's network access:
9186thv run --isolate-network context7
9287```
9388
89+ If you have a Context7 API key for higher rate limits, create a secret named
90+ ` context7 ` containing your API key and run the server with the ` --secret ` flag:
91+
92+ ``` bash
93+ thv secret set context7
94+ thv run --secret context7,target=CONTEXT7_API_KEY context7
95+ ```
96+
9497Combine API key with network isolation:
9598
9699``` bash
97- thv run --isolate-network context7 -- --api-key $( thv secret get context7)
100+ thv run --secret context7,target=CONTEXT7_API_KEY --isolate-network context7
98101```
99102
100103</TabItem >
@@ -109,7 +112,7 @@ metadata:
109112 name : context7
110113 namespace : toolhive-system
111114spec :
112- image : ghcr.io/stacklok/dockyard/npx/context7:1.0.14
115+ image : ghcr.io/stacklok/dockyard/npx/context7:1.0.21
113116 transport : stdio
114117 port : 8080
115118` ` `
@@ -120,21 +123,23 @@ Apply the manifest to your cluster:
120123kubectl apply -f context7.yaml
121124```
122125
123- For higher rate limits, add your API key as a command-line argument:
126+ If you have a Context7 API key for higher rate limits, create a Kubernetes
127+ secret containing your Context7 API key:
124128
125- ``` yaml {8} title="context7-with-auth.yaml"
126- apiVersion : toolhive.stacklok.dev/v1alpha1
127- kind : MCPServer
128- metadata :
129- name : context7
130- namespace : toolhive-system
129+ ``` bash
130+ kubectl -n toolhive-system create secret generic context7-api-key --from-literal=token=< YOUR_TOKEN>
131+ ```
132+
133+ Then add a ` secrets ` section to the manifest file above to pass the API key as
134+ an environment variable:
135+
136+ ``` yaml title="context7-with-auth.yaml"
131137spec :
132- image : ghcr.io/stacklok/dockyard/npx/context7:1.0.14
133- args :
134- - ' --api-key'
135- - ' YOUR_API_KEY'
136- transport : stdio
137- port : 8080
138+ # ...
139+ secrets :
140+ - name : context7-api-key
141+ key : token
142+ targetEnvName : CONTEXT7_API_KEY
138143` ` `
139144
140145</TabItem>
@@ -159,10 +164,10 @@ Here are practical prompts you can use with the Context7 MCP server:
159164
160165# # Recommended practices
161166
162- - Add `use context7` to your prompts to automatically fetch up-to-date
167+ - Include `use context7` in your prompts to automatically fetch current
163168 documentation for the libraries you're working with.
164- - When you know the exact library, you can specify it directly using the
165- Context7 ID format : ` use library /supabase/supabase for api and docs`
169+ - When you know the exact library, specify it directly using the Context7 ID
170+ format, for example : ` use library /supabase/supabase for api and docs`
166171- Consider setting up a rule in your MCP client to automatically invoke Context7
167172 for code-related queries, eliminating the need to manually add `use context7`
168173 to each prompt.
0 commit comments