MCP#
gptme works as both an MCP client (consuming external MCP servers) and an MCP server (exposing gptme tools to Claude Desktop, Cursor, and other MCP clients).
Configuration#
You can configure MCP in your Global config (~/.config/gptme/config.toml) file:
[mcp]
enabled = true
auto_start = true
[[mcp.servers]]
name = "my-server"
enabled = true
command = "server-command"
args = ["--arg1", "--arg2"]
env = { API_KEY = "your-key" }
# HTTP MCP Server example
[[mcp.servers]]
name = "http-server"
enabled = true
url = "https://example.com/mcp"
headers = { Authorization = "Bearer your-token" }
# Legacy SSE MCP server example (URL ends in /sse, so SSE is auto-detected)
[[mcp.servers]]
name = "sse-server"
enabled = true
url = "https://example.com/sse"
HTTP servers use the streamable-HTTP transport by default. A URL whose path ends
in /sse (the conventional FastMCP SSE endpoint) is connected over the legacy
SSE transport instead. For an SSE endpoint at any other path, set
transport = "sse" explicitly; transport is ignored for stdio servers.
The same [mcp] settings are supported in Project config
(gptme.toml in your workspace) and per-conversation configuration.
For example, a project’s gptme.toml can enable its own server:
[mcp]
enabled = true
[[mcp.servers]]
name = "project-server"
command = "server-command"
args = ["--arg1"]
Servers from all configuration layers are combined. For servers with the same
name, conversation settings take precedence over project settings, which take
precedence over global settings. The winning entry replaces the others whole:
fields from a lower layer’s entry are not merged into it. gptme-util mcp info
prints which layer supplied a server (Source:) and which layers it
overrides. The enabled and auto_start settings follow the same precedence.
Run gptme-util mcp list, gptme-util mcp test project-server, or
gptme-util mcp info project-server from the workspace directory to inspect
and test the merged global and project configuration. Before connecting to a
project-defined server, these commands ask for confirmation and show the target
command or URL (credentials in an HTTP URL — userinfo and query/fragment
parameter values — are redacted). Declining or
supplying no input skips the connection; mcp test exits unsuccessfully. Connecting to a stdio server runs its configured command,
so approve only project servers you trust.
The /mcp load confirmation also shows which layer defines the server and the
command (or URL) it would start, with the load’s overrides applied. Command
arguments and environment values are masked by the same rules as for imported
servers below; a configured URL keeps its path, with userinfo and query/fragment
values masked. A server that an earlier load added or changed with an override is
labelled as such, not as coming from a config file. If the definition or the
load’s override changes between that confirmation and the load, the load is
refused and has to be requested again.
Servers from other MCP clients#
If you already configured MCP servers in another client, gptme finds them without any extra setup. It reads:
Claude Code: user-scope servers in
~/.claude.json(or$CLAUDE_CONFIG_DIR/.claude.json) and local-scope servers for the current workspace. Servers you disabled for the project in Claude Code’s/mcpare skipped. Project.mcp.jsonservers are discovered only if you enabled them in the matching project record in your user-owned.claude.json(enabledMcpjsonServersorenableAllProjectMcpServers). This only allows discovery; it does not approve starting them in gptme. Servers bundled with plugins you installed and enabled at user scope (enabledPluginsin~/.claude/settings.json) are listed asplugin_<plugin>_<server>. Plugins enabled only by a project’s.claude/settings.jsonare not imported, so a repository cannot add one.Codex:
[mcp_servers]in~/.codex/config.toml(or$CODEX_HOME), includingbearer_token_env_varandenv_http_headers.Cursor:
~/.cursor/mcp.json.${workspaceFolder}and${workspaceFolderBasename}refer to gptme’s workspace. They are not expanded incommand(a server using them there is skipped), but they are inargsandenv: an entry such aspython ${workspaceFolder}/server.pyruns a file from the workspace, so check the/mcp loadconfirmation before accepting it.Claude Desktop:
claude_desktop_config.jsonin the platform config directory.
These servers are discovered, not started. They never connect when gptme
starts; they are listed by /mcp list and gptme-util mcp list with the
file they came from, and connect only when you load one with
/mcp load <name> (which also works when [mcp] enabled = false) or check
it with gptme-util mcp test <name>. The /mcp load confirmation shows the
file the server came from and the expanded command and arguments (or the URL’s
origin). The preview is for the person approving the load, so values substituted
from the environment are shown: any argument may be what an interpreter or
package runner is asked to run. In the arguments it masks only credentials: the
value of a credential flag, the value in a whole argument such as
API_KEY=... or Authorization: ..., and URL userinfo and credential-named
query parameters. Without a space after the colon, a name:value argument is
masked only if the last word of the name is such a word or auth, so the tag
of an image like vault-token-mcp:2.1.0 stays visible. A credential flag has a word such as token, key,
secret, password, cookie or authorization in its name, or ends
in auth (--github-token x, --openai-api-key=x, --basic-auth x).
It also does not end in a word such as file, path, command,
script, process, stdin or id, and does not start with no,
skip, disable, require, use, enable, without,
allow, with or ask. auth anywhere else does not count
(--auth-hook is shown). Words are matched whole, so fused names count only
if gptme lists them (--apitoken, --secretkey, --dbpassword).
Nothing else inside a longer argument is masked, and neither is the command
itself, the operand of a code flag such as -c or -e, or a value that
starts with - or contains whitespace (other than after Bearer,
Basic or Token), a backtick or one of ( ) ; { } | & $ < >. A
-D system property is masked only in its -Dname=value form. A
NAME=value argument is masked if any word of the name is a credential word
or auth (AUTH_HEADER=...), unless the last word says the value is
something else (TOKEN_COMMAND; not url, uri or header). The
preview can therefore show a secret rather than hide code. Environment settings
that make a process load or execute code, such as NODE_OPTIONS,
JAVA_TOOL_OPTIONS, PYTHONPATH, BASH_ENV, LD_*, DYLD_* and
askpass programs, are never masked, including any credentials inside them,
whether they are set in env or as a NAME=value argument. Package sources
(NPM_CONFIG_REGISTRY, UV_INDEX, UV_DEFAULT_INDEX, UV_INDEX_URL,
UV_EXTRA_INDEX_URL, UV_FIND_LINKS, PIP_INDEX_URL,
PIP_EXTRA_INDEX_URL, PIP_FIND_LINKS, BUN_CONFIG_REGISTRY,
YARN_NPM_REGISTRY_SERVER) are shown
with only URL userinfo and credential-named query parameters masked. Other
env values are hidden unless they may be code by the same rule as above,
they are the workspace path or a path below it (then shown even under
credential-like names) or the load overrides env. A credential-like name
whose last word says the value is something else, as for flags
(TOKEN_COMMAND, KEY_FILE, API_KEY_HELPER), is shown too, except when
that word is url, uri or header, whose value can be the secret
itself. Two secret shapes are recognised before these rules, never in a
code-loading or package-source key or under a name ending in such a “something
else” word (SERVER_COMMAND, KEY_FILE). Under a credential-like name, a
value that consists only of well-formed PEM blocks (the -----BEGIN line,
optional Proc-Type and DEK-Info lines, base64 lines and the matching
-----END line; newlines may be written as a literal \n) is hidden.
Under a credential-like name or a key with a word such as DSN,
CONNECTION or DB, a value that consists only of ;-separated
name=value segments (names of letters, digits, spaces, dots and
underscores) and has no newline, backtick or one of | & $ ( ) < > has the
value of a password, pwd, accountkey, sharedaccesskey,
secret or token field masked, unless it contains whitespace or has
whitespace before it. No field is masked if any field value has a quote
character, unless that value is one quoted string of only letters, digits and
. _ - + / = @ : ! % ^ * ~.
Generated Claude plugin paths stay readable before the directories
exist.
gptme-util mcp list --json is
the machine-readable form: names, types and sources only, no commands, env,
headers or URLs, and it does not connect. A server defined in gptme’s own config
always wins over one with the same name from another client, and gptme’s own
MCP server is never imported into itself. Imported entries are kept in memory
only: gptme does not copy them, or any secrets in their env or
headers, into its config or conversation files.
At session start the agent is told the names (and source client) of up to 20
imported servers, so it knows it can /mcp load one on demand. These are
serialized as untrusted JSON metadata in a separate user-role message, not as
system instructions. Entries longer than 512 serialized characters are omitted
rather than renamed; /mcp list shows the remaining servers. Commands, URLs
and env are never included.
Starting an imported server always takes a person. When the agent asks to load
one, you are asked to approve it, and the load is refused when nobody
answers: in non-interactive and --no-confirm runs, while auto-confirm is
active, over ACP, and in subagents. Typing /mcp load <name> yourself counts
as approval. gptme-util mcp test <name> shows the imported source and
command (or redacted HTTP target), then asks before connecting; declining,
pressing Enter or supplying no input does not start it. This requires an
interactive terminal: piped input, even y, cannot approve an imported
connection. To use such a server in unattended runs, define it in gptme’s own
config.
Repository .mcp.json servers require a separate human review of the raw
repository definition before their first load. The review also shows the
expanded launch command. Approval is pinned to the exact definition and its
project directory; changing any definition field requires another review.
A typed /mcp load or a prior server-client approval cannot skip this review.
An override cannot grant trust to a repository definition: review it without
overrides first. Even after review, every load still needs a person, so stored
trust never enables auto-confirm or unattended execution. That per-load prompt
also defaults to No for a repository server: trust covers the definition, not
the scripts or packages it launches, which a git pull can change.
gptme-server cannot show the repository review, so review the definition in a
terminal before loading the server there. gptme-util mcp test
also asks separately to trust the raw definition, after its terminal-only
connection prompt.
Only the .mcp.json in the directory named by the nearest matching Claude
Code project record is read. A nested repository file cannot inherit a parent
record’s approval. Unapproved, disabled or unsupported project entries do not
hide your same-named user servers. Names must be 1–64 plain ASCII letters,
digits, dots, underscores or hyphens, starting with a letter or digit. Environment
references in repository commands, URLs or headers are rejected rather than
expanded; args and env references are shown at review time. Relative paths run
from the directory supplying the reviewed .mcp.json, including reconnects.
Imported provenance
and secret hiding remain in effect after unloading a server.
Some things do not carry over:
Logins. An HTTP server that another client signed in to with OAuth (for example one added with
claude mcp add --transport http) goes through gptme’s own OAuth flow (see OAuth for HTTP servers below) the first time it is loaded. gptme does not read other clients’ stored tokens.claude.ai connectors (Gmail, Google Drive, …) belong to your claude.ai account rather than a local config file, so they cannot be imported.
Cursor project files (
.cursor/mcp.json) are not imported. Use agptme.toml[mcp]section, which goes through project trust.Plugin servers packaged as MCP bundles (
.mcpb), or that need a plugin option (${user_config.KEY}), are skipped.WebSocket servers and
headersHelperare not supported yet.
Set GPTME_MCP_IMPORT (environment, or MCP_IMPORT under [env] in
config.toml) to control this: 0 turns importing off, 1 (or unset)
imports from every client, and a
comma-separated list such as claude-code,codex limits it to those clients
(claude-code, codex, cursor, claude-desktop).
Note that the per-server enabled = false setting works the same way for
gptme’s own servers: a disabled server does not connect at startup, and
/mcp load <name> starts it on demand.
Management Tool#
gptme includes a powerful MCP management tool that allows you to discover and dynamically load MCP servers during a conversation.
Commands#
The mcp tool provides the following slash-commands:
/mcp search [query]: Search for MCP servers across registries/mcp info <server-name>: Get detailed information about a specific server/mcp load <server-name>: Dynamically load an MCP server into the current session/mcp unload <server-name>: Unload a previously loaded MCP server/mcp list: List all currently configured and loaded MCP servers
When a registry remote needs a manual URL or HTTP headers, use its full
registry ID (for example, io.github.example/server) with the JSON load
override. Provide each required header that has no applicable default. Header
names are matched case-insensitively, with explicit entries taking precedence.
A URL that fills a registry hostname template may inherit static headers
explicitly marked non-secret. Credential and variable-derived headers are not
carried to a new origin. A URL outside the registered origin or hostname template
inherits no headers. Use a standalone name for an independent URL, including
when repointing an already loaded registry entry to another origin.
It also exposes /mcp resources list|read, /mcp templates list,
/mcp prompts list|get, and /mcp roots list|add|remove.
Once loaded, the server’s tools will be available as <server-name>.<tool-name> in the conversation.
Configuration Options#
enabled: Enable/disable MCP support globallyauto_start: Automatically start MCP servers when neededservers: List of MCP server configurationsname: Unique identifier for the serverenabled: Enable/disable individual servercommand: Command to start the server (for stdio servers)args: List of command-line arguments (for stdio servers)url: HTTP endpoint URL (for HTTP servers)headers: HTTP headers dictionary (for HTTP servers)transport:"sse"to force the legacy SSE transport for an HTTP server (auto-detected for URLs ending in/sse); otherwise streamable HTTP is usedenv: Environment variables for the server
OAuth for HTTP servers#
Some HTTP servers gate access with OAuth instead of a static token. When such a
server answers 401 with a resource_metadata challenge, gptme runs the MCP
authorization-code flow (PKCE) against the authorization server it advertises,
including dynamic client registration and token refresh:
the authorization URL is printed and opened in a browser when one is available,
the redirect is captured on a loopback port (
127.0.0.1), as RFC 8252 requires for native clients; later sessions reuse the registered port, or register again when it is taken,the issued token and client registration are cached per server under
mcp-oauth/in the config directory, in a0600file.
An Authorization value in [mcp.servers.headers] always wins over the
flow, so existing static-token setups keep working unchanged. Set
GPTME_MCP_OAUTH=0 to disable the flow entirely.
A session that cannot open a browser (server mode, CI) fails with an actionable error instead of waiting for a redirect: authorize once interactively to fill the cache, or keep using static headers.
Large tool results#
A tool result longer than 100,000 characters (about 25k tokens) is cut to its head and tail
before it reaches the model. When a conversation directory is active, the full text is saved
under tool-outputs/ and the omission marker names the file. Set
GPTME_MCP_MAX_OUTPUT_CHARS to change the limit. The limit counts the kept content; the
omission notice and file path are added on top of it.
MCP Server Examples#
SQLite Server#
The SQLite server provides database interaction and business intelligence capabilities through SQLite. It enables running SQL queries, analyzing business data, and automatically generating business insight memos:
[[mcp.servers]]
name = "sqlite"
enabled = true
command = "uvx"
args = [
"mcp-server-sqlite",
"--db-path",
"/path/to/sqlitemcp-store.sqlite"
]
The server provides these core tools:
Query Tools:
read_query: Execute SELECT queries to read datawrite_query: Execute INSERT, UPDATE, or DELETE queriescreate_table: Create new tables in the database
Schema Tools:
list_tables: Get a list of all tablesdescribe_table: View schema information for a specific table
Analysis Tools:
append_insight: Add business insights to the memo resource
Resources:
memo://insights: A continuously updated business insights memo
The server also includes a demonstration prompt mcp-demo that guides users through database operations and analysis.
Chrome DevTools Server#
The Chrome DevTools MCP server exposes Chrome DevTools Protocol capabilities — DOM inspection, network traffic analysis, JavaScript console, performance profiling, and Lighthouse audits — directly as MCP tools.
Requires Node.js and npx.
[[mcp.servers]]
name = "chrome-devtools"
enabled = true
command = "npx"
args = ["-y", "chrome-devtools-mcp@latest"]
The server provides tools across several categories:
Navigation:
navigate_page,new_page,close_page,select_pageInspection:
take_snapshot,take_screenshot,evaluate_scriptNetwork:
list_network_requests,get_network_requestConsole:
list_console_messages,get_console_messagePerformance:
performance_analyze_insight,lighthouse_auditAutomation:
click,type_text,fill_form,hover,drag
Useful flags:
--headless— run without a visible window (server environments)--isolated— clean browser state per session--slim— navigation and screenshots only (lightweight)
For example, to run headless with an isolated browser profile:
[[mcp.servers]]
name = "chrome-devtools"
enabled = true
command = "npx"
args = ["-y", "chrome-devtools-mcp@latest", "--headless", "--isolated"]
Kling AI Server (remote, OAuth)#
Kling AI runs an official remote MCP server for its video and
image generation (Official MCP Registry ID: io.github.klingai-dev/kling-ai). It is a
streamable-HTTP server protected by OAuth 2.1, so it needs no local install and no static
API key:
[[mcp.servers]]
name = "kling"
enabled = true
url = "https://kling.ai/mcp/plugin"
An unauthenticated request to this endpoint returns 401 with a resource_metadata
challenge, which starts the flow described in OAuth for HTTP servers above: on first
use gptme prints the authorization URL (and opens it in a browser when it can), you sign in
to your Kling account, and the token is cached for later sessions. Run the first
connection from an interactive session, then check it with gptme-util mcp test kling.
Do not set an Authorization header for this server, since a header overrides the OAuth
flow. Generation uses your Kling account’s credits. Kling also publishes a
Claude plugin with a SKILL.md pack and a
setup guide; see Skills for how gptme loads skills.
Running MCP Servers#
Each server provides its own set of tools that become available to the assistant.
MCP servers can be run in several ways:
Using package managers like
npx,uvx, orpipxfor convenient installation and executionRunning from source or pre-built binaries
Using Docker containers
Warning
Be cautious when using MCP servers from unknown sources, as they run with the same privileges as your user.
You can find a list of available MCP servers in the example servers and MCP directories like MCP.so.
Managing MCP Servers#
gptme provides CLI commands to manage and test your MCP servers:
# List all configured MCP servers and check their health
gptme-util mcp list
# JSON listing of configured and imported servers (no connection tests)
gptme-util mcp list --json
# Test connection to a specific server
gptme-util mcp test server-name
# Show detailed information about a server
gptme-util mcp info server-name
These commands help you verify that your MCP servers are properly configured and accessible.
gptme as an MCP Server#
gptme can expose its own tools (shell, Python REPL, file read/save, browser, etc.) as an MCP server so that Claude Desktop, Cursor, and other MCP clients can use them directly.
Quick start for Claude Desktop — add to claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude on Windows):
{
"mcpServers": {
"gptme": {
"command": "gptme-mcp-server",
"args": ["--tools", "shell,ipython,save,read"]
}
}
}
Then restart Claude Desktop. The shell, ipython, save, and read tools will appear in Claude’s tool menu.
Running the server manually:
# Standalone entrypoint (recommended for Claude Desktop)
gptme-mcp-server --tools shell,ipython,save,read
# Or via gptme-util (equivalent)
gptme-util mcp serve --tools shell,ipython,save,read
Options:
--profile: Tool preset.defaultexposesshell,ipython,save,append,read, which suits clients without a shell such as Claude Desktop.agentexposesask_model,search_chatsfor coding agents (Claude Code, Codex, Cursor), which already have their own shell and file tools; see below.--tools: Comma-separated tool names to expose; overrides--profile.subagentandmcpare always excluded.--workspace DIR: Working directory for all tool operations (default: current directory).--log-level: Log level sent to stderr (DEBUG,INFO,WARNING,ERROR).
Registering it in a client. gptme-util mcp install adds the server to Claude Code, Codex,
Cursor or Claude Desktop, with an absolute path so that GUI clients find it:
gptme-util mcp install --client claude-code
gptme-util mcp install --client codex --client cursor
Coding agents get the agent profile described below and Claude Desktop the default tools; pass
--tools to choose others. For Claude Code the server is registered for all projects and can be
turned off per project in /mcp; use --scope local for the current project only. Running the
command again updates the executable but keeps the existing tool/profile selection unless you
pass --tools explicitly. gptme-util mcp uninstall --client ... removes it. Only a server
named gptme that runs gptme is changed. If you added server arguments such as --workspace
or --log-level, or launcher options such as --with, --python or a pinned package
version, install refuses to overwrite them; update that entry in the client’s configuration instead.
Other entry fields are preserved. Restart Claude Desktop to pick up a change.
For coding agents. Claude Code, Codex and Cursor already have a shell and file tools, so
the default set would only add a second shell that bypasses the host’s permission rules. Use the
agent profile instead, which exposes things they cannot do (mcp install does this for you):
claude mcp add gptme -- gptme-mcp-server --profile agent
ask_model: run one prompt through any model gptme is configured for (modelasprovider/model) and return the answer, for a second opinion, a cross-check or cheap fan-out. The model has no tools and cannot see your files, and the prompt is sent to that provider. Bounded: prompt up to 100,000 characters,max_tokensup to 8,000 (default 2,000),timeoutup to 600 s (default 120 s), answer truncated at 20,000 characters with the model’s reasoning left out, and at most 4 timed-out calls still running in the background.search_chats: search past gptme conversation logs and return the matching excerpts. Bounded: up to 20 conversations, output truncated at 20,000 characters. The scan goes newest first and stops after 30 s, returning what it found and saying that older conversations were not searched.
The server is session-backed: one persistent gptme session per MCP connection, so the bash shell retains state, the Python REPL keeps variables, and file operations share a consistent working directory across multiple tool calls.