CodingOpen SourceFreeActiveMachine-verified· intermediate · ~10 min setup

Kilo Code: add an MCP tool and bind it to one mode

Enable an MCP server's tools only on the mode that needs it (a researcher), so its tool definitions don't load into every conversation and burn tokens.

by Shilpa Mitra· verified today· v1.0.0

Run this workflow

CI-verified, 2/2 fixtures passing.

Build this with your agent

One copy-paste hands Claude Code, Codex, or Cursor the full recipe, steps included, nothing to fetch.

Intended Use

Anyone adding MCP tools to Kilo without bloating every mode's context. CI validates that .kilocodemodes parses, the researcher mode carries the mcp group, and the code mode does not. No key, no network. The model using the tool is fenced.

Not for

  • Enabling the mcp group on every mode, each server's tool definitions cost tokens per turn, so scope it
  • Assuming a one-click marketplace server is safe, it's third-party code with access to your tools; vet the source

The Stack

Tested Against

kilocode@7.3.45kilo.ai/docs (2026-06)ruby@3.x (YAML stdlib)

Side effects & data flow

Network
none, local only
Writes
./.kilocodemodes
Credentials
none required

Prerequisites

  • Kilo Code extension installed
  • An MCP server installed from the marketplace to actually use it

Steps

  1. 1

    Scope the mcp group to one mode and validate

    In .kilocodemodes, give the researcher mode the mcp group and leave the code mode without it. Install the server from the in-app MCP Marketplace, then it surfaces only in the researcher mode. CI parses the file and asserts researcher carries mcp while code does not.

    cat > .kilocodemodes <<'YAML'
    customModes:
      - slug: researcher
        name: Researcher
        roleDefinition: You answer questions using the codebase and approved external tools.
        groups:
          - read
          - mcp
      - slug: code
        name: Code
        roleDefinition: You implement changes.
        groups:
          - read
          - edit
    YAML
    ruby -ryaml -e '
    c = YAML.load_file(".kilocodemodes")
    modes = c["customModes"] || []
    researcher = modes.find { |x| x["slug"] == "researcher" }
    code = modes.find { |x| x["slug"] == "code" }
    abort "BAD: missing researcher or code mode" unless researcher && code
    abort "BAD: researcher lacks the mcp group" unless (researcher["groups"] || []).include?("mcp")
    abort "BAD: code should not carry the mcp group" if (code["groups"] || []).include?("mcp")
    puts "config OK: only the researcher mode carries the mcp group; code stays clean"
    '
  2. 2

    Install and use the MCP server (the model step, not checked by CI)

    Browse the in-app MCP Server Marketplace, install the server, and assign it to the researcher mode. Its tools load only there. The model actually calling the tool is fenced.

Eval, 2 fixtures

Last passed: verified today
  • mcp-scopedcontainstimeout 30s · max $0

    Expected: config OK: only the researcher mode carries the mcp group; code stays clean

  • clean-exitexit_codetimeout 30s · max $0

    Expected: 0

Results

One-click MCP from the marketplace, then scoped: the researcher mode carries the mcp group and your code mode stays clean, so external tools load only where you need them.

Did this work for you?

Our CI checks the setup runs. You tell us if the whole thing worked. Tell us straight.

Liked this workflow?

Get new verified workflows in WebAfterAI, three issues a week (Tue, Thu, Sat).