LatentCodeCustomize

MCP servers

Connect LatentCode to other tools and data, such as issue trackers, databases and internal APIs, through the Model Context Protocol.

Add a server

$latentcode mcp add

The wizard asks for a name, whether the server is Local (a command LatentCode starts) or Remote (a URL), and whether it uses OAuth. Inside a git repository it also asks whether to save it to the current project or globally. To add one in a single command (saved globally):

Bash
# local: everything after -- is the command to run
latentcode mcp add files -- npx -y @modelcontextprotocol/server-filesystem ~/Documents

# remote, with a header
latentcode mcp add tracker --url https://tracker.example.com/mcp --header "Authorization=Bearer $TRACKER_TOKEN"

Check that it connects:

$latentcode mcp list
✓ files connected
    npx -y @modelcontextprotocol/server-filesystem /Users/you/Documents
⚠ tracker needs authentication
    https://tracker.example.com/mcp

Configure servers in latentcode.json

Servers live under mcp, keyed by name:

latentcode.json
{
  "mcp": {
    "postgres": {
      "type": "local",
      "command": ["npx", "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/app_dev"],
      "environment": { "PGPASSWORD": "{env:PGPASSWORD}" }
    },
    "tracker": {
      "type": "remote",
      "url": "https://tracker.example.com/mcp",
      "headers": { "Authorization": "Bearer {env:TRACKER_TOKEN}" }
    },
    "wiki": {
      "type": "remote",
      "url": "https://wiki.example.com/mcp",
      "oauth": {}
    }
  }
}

Local servers

type"local"required
commandstring[]required
The command and its arguments.
environmentobjectoptional
Environment variables for the command.
cwdstringoptional
Working directory, relative to the project.
enabledbooleanoptionaldefault true
Set to false to keep the entry but not start it.
timeoutintegeroptional
Milliseconds to wait for requests to the server.

Remote servers

type"remote"required
urlstringrequired
The server's URL.
headersobjectoptional
HTTP headers to send, for example an API token.
oauthobject | falseoptional
OAuth settings (below). false turns OAuth off even if the server asks for it.
enabledbooleanoptionaldefault true
timeoutintegeroptional
Milliseconds to wait for requests to the server.

To turn off a server defined in another config file, for example in one project, set "mcp": { "tracker": { "enabled": false } }. /mcps in the TUI turns servers on and off with space.

Log in with OAuth

  1. 1
    Add the server with an oauth block

    "oauth": {} is enough for servers that support automatic client registration. Otherwise add the clientId (and clientSecret) you registered with the provider.

  2. 2
    Authenticate
    $latentcode mcp auth tracker

    Your browser opens the provider's login page. After you approve, it redirects to LatentCode on http://127.0.0.1:19876/mcp/oauth/callback.

  3. 3
    Check

    latentcode mcp auth list shows each OAuth server and whether you're logged in.

oauth fieldMeaning
clientIdClient ID registered with the provider. Omit it to register automatically.
clientSecretClient secret, if the provider issued one.
scopeScopes to request.
callbackPortPort for the redirect. Default 19876.
redirectUriFull redirect URI, if the provider needs a specific one.

Credentials are stored locally, readable only by you. Log out with latentcode mcp logout tracker. If a login fails, latentcode mcp debug tracker walks through the OAuth steps and shows where it stops.

Using MCP tools

  • The agent sees each tool as <server>_<tool>, for example tracker_create_issue.
  • Tools are allowed by default. Control them with permissions: "permission": { "tracker_*": "ask" }.
  • Prompts the server offers appear as slash commands; resources appear in the @ menu.
  • The sidebar and /status show each server's status.
Every tool costs context
Each connected server's tool descriptions are sent with every request. Turn off servers you aren't using.

Troubleshooting

mcp list shows "failed"

The error follows the status. For local servers, run the command yourself to see its output; check that it's on your PATH. Start LatentCode with --print-logs for details.

"needs authentication"

Run latentcode mcp auth <name>.

"needs client registration"

The server doesn't support automatic registration. Register a client with the provider and add clientId to the server's oauth block.

The browser login never returns

Something else may be using port 19876. Set a different callbackPort.