Skip to content

MCP Integration

LongerAgent supports the Model Context Protocol (MCP) for connecting to external tool servers. MCP servers provide additional tools that the agent can use alongside its built-in tools.

Configuration

MCP servers are configured in ~/.longeragent/mcp.json. This file is optional and user-edited (it is not created by longeragent init).

Format

The file is a JSON object where each key is a server name and each value is a server configuration:

json
{
  "filesystem": {
    "transport": "stdio",
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/dir"]
  },
  "github": {
    "transport": "stdio",
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-github"],
    "env": {
      "GITHUB_TOKEN": "${GITHUB_TOKEN}"
    }
  }
}

Configuration Fields

FieldTypeRequiredDescription
transport"stdio" or "sse"NoTransport protocol. Default: "stdio".
commandstringYes (stdio)The command to run the MCP server.
argsstring[]NoArguments passed to the command.
urlstringYes (sse)URL for SSE transport servers.
envobjectNoEnvironment variables passed to the server process. Supports ${VAR} syntax to reference your shell environment.
env_allowliststring[]NoList of environment variable names to pass through from the parent process.
sensitive_toolsstring[]NoTool names that should be treated as sensitive (may require extra confirmation).

Environment Variable Resolution

Environment variables in the env field support the ${VAR} syntax:

json
{
  "env": {
    "API_KEY": "${MY_API_KEY}"
  }
}

This resolves ${MY_API_KEY} from your shell environment at startup. If the variable is not set, LongerAgent will throw an error.

Transport Types

stdio (Default)

The most common transport. LongerAgent spawns the MCP server as a child process and communicates via stdin/stdout.

json
{
  "my-server": {
    "transport": "stdio",
    "command": "node",
    "args": ["path/to/server.js"]
  }
}

SSE

For servers that run as a separate HTTP service. LongerAgent connects to the server's SSE endpoint.

json
{
  "remote-server": {
    "transport": "sse",
    "url": "http://localhost:3000/sse"
  }
}

Using MCP Tools

Once configured, MCP tools are available to the agent automatically. They appear alongside the built-in tools. You do not need to do anything special to use them -- the agent discovers and calls MCP tools as needed.

You can also run /mcp inside LongerAgent to connect the configured servers on demand and list the discovered tools. This works before your first agent turn, which makes it a useful quick verification step.

Example: Adding a Database Tool

json
{
  "sqlite": {
    "transport": "stdio",
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-sqlite", "path/to/database.db"]
  }
}

After saving this to ~/.longeragent/mcp.json and restarting LongerAgent, run /mcp to verify the SQLite tools were discovered. The agent will then be able to call them during normal turns.

Released under the MIT License.