· 8 min read
Cline Uses MCP, Subagents & Custom Tools for Agentic Coding
By T. Taylor
- guides
How Cline uses MCP, subagents, and custom tools for agentic coding is straightforward: MCP connects the main agent to external services and data sources; subagents perform parallel, read-only codebase investigation; and custom tools let engineers add application-specific functions to an agent runtime. They solve different parts of the agentic-coding loop—capability, context discovery, and reliable execution—so treating them as interchangeable usually produces an overpowered, expensive, or unsafe setup.
How Does Cline Use MCP for Agentic Coding?
Model Context Protocol (MCP) is the integration boundary. In Cline, an MCP server exposes tools and resources that the agent can discover and call, letting a coding task reach systems outside the repository: an internal API, a database, issue tracker, deployment platform, or service-specific workflow. Cline supports local STDIO servers and remote hosted servers over Streamable HTTP or legacy SSE. The result is that the agent can use an external capability as a typed tool call instead of relying on pasted output or a fragile prompt convention.
In a practical coding task, MCP belongs at the edge of the system. Imagine fixing a production bug: the main agent reads the code, runs tests, and proposes an edit. An MCP tool might retrieve a sanitized error trace, inspect a feature-flag state, or query a read-only service endpoint to confirm the hypothesis. The model chooses the tool, the MCP server executes the integration logic, and the returned result becomes evidence for the next step. MCP is not the model itself, and it is not a replacement for ordinary local file or terminal operations.
The configuration choice matters. Use a local STDIO server when the tool is specific to one developer machine or workspace and a local process is the simplest trust boundary. Use a remote server when a team needs a centrally operated integration. In either case, credentials should live in environment variables or an appropriate secret mechanism—not in prompts, repository configuration, or tool descriptions. Cline’s MCP guidance also recommends installing only trusted servers, limiting auto-approval to safe tools, and reviewing tool calls that can have consequences.
What Is the Difference Between MCP and Built-In Tools?
Built-in tools are the agent’s general development primitives: reading and searching files, editing code, running commands, fetching web content, and asking the user questions. MCP adds external, separately implemented capabilities. A useful rule is: if the action is fundamentally about the checked-out workspace, start with the built-in tool set; if it crosses into an external product, data store, or organization-specific service, MCP is usually the cleaner integration surface.
That distinction protects maintainability. A tool called get_release_status backed by an MCP server can have stable inputs, access controls, audit logging, and a single maintained implementation. Asking an agent to reconstruct the same workflow by scraping a dashboard or chaining shell commands may work once, but it makes behavior dependent on UI changes and accidental context. MCP gives the organization a contract; the agent supplies the planning and judgment around that contract.
How Do Cline Subagents Work?
Cline subagents are focused research workers launched by the main agent. Each gets its own prompt, context window, and token budget, investigates a bounded question, then returns a report identifying the most relevant findings and file paths. They are enabled by default, though they can be disabled, and Cline can decide when parallel investigation is worthwhile. You can also ask for it explicitly: for example, ask it to investigate authentication, the persistence layer, and the test harness in parallel before changing a cross-cutting feature.
The crucial limitation is deliberate: subagents are read-only researchers. They can read files, list directories, search code, inspect definitions, execute read-only commands, and use skills. They cannot edit files, apply patches, browse the web, call MCP servers, or create nested subagents. That means a subagent should map an unfamiliar code path or compare implementation options; the main agent remains responsible for deciding, changing code, and using privileged integrations.
This architecture addresses the context problem in large repositories. A single agent that serially explores routing, authorization, schemas, migrations, and tests fills its context with intermediate detail before it writes a line. Parallel research distributes that exploration, then gives the primary agent concise reports to verify and act on. But subagents are not free: their tokens and inference cost are included in the task total. For a two-file bug where the relevant code is known, delegation adds coordination overhead rather than useful signal.
When Should You Use Subagents for Coding Tasks?
- Use them before an edit that touches several independent areas: API contracts, UI state, migrations, tests, and deployment configuration.
- Use them to onboard to an unfamiliar repository by assigning narrow questions such as “find entry points,” “trace authorization,” and “explain test fixtures.”
- Use them for competing read-only investigations, such as locating all call sites while another worker reviews backward-compatibility risks.
- Do not use them for a small, localized edit, for actions requiring external access, or as a way to bypass approval boundaries.
The best subagent prompt looks like an engineering investigation ticket, not a vague request to “understand the code.” State the subsystem, the question to answer, the expected output, and any boundaries. For example: “Trace how accountId travels from the HTTP handler to the billing client. Identify files and tests that must change to support a nullable value; do not propose edits.” That framing creates a report the main agent can evaluate rather than a long narrative it has to rediscover.
How Do Custom Tools Work in Cline?
Custom tools are an SDK-level way to add functions directly to an agent. A tool has a unique name, a description read by the model, an input schema, and an execute function that performs the work. In the Cline SDK, createTool accepts Zod or JSON Schema inputs, and tools can be supplied to a session, passed when constructing an agent, or registered through a plugin. The SDK is the same underlying agent harness used by Cline’s IDE extensions and CLI, but this custom-tool interface is for engineers embedding or extending that runtime rather than merely configuring an IDE session.
Use a custom tool when you own a narrow capability and want deterministic code to implement it: validate a generated migration against internal policy, look up a service catalog record, invoke a company linter with structured results, or calculate a deployment impact score. Unlike a prompt instruction, a tool exposes typed arguments and controlled execution. Unlike a broadly reusable MCP server, it can be the right choice for a capability that belongs inside one agent application or plugin.
import { createTool } from "@cline/sdk"
import { z } from "zod"
const checkMigration = createTool({
name: "check_migration",
description: "Validate a migration file. Returns errors and warnings as JSON.",
inputSchema: z.object({ path: z.string().describe("Workspace-relative SQL file") }),
async execute({ path }) {
return await validateMigration(path)
},
})How Should You Design Custom Agent Tools?
Tool descriptions are part of the control plane, not decoration. State what the tool does, what it returns, when it should and should not be used, and hard constraints such as read-only behavior, maximum result size, or required approval. Describe every input property. Return structured JSON where possible so the model can reliably distinguish a successful result, a warning, and an error. For longer work, honor cancellation through the provided execution context; for recoverable failures, return a structured error rather than throwing and obscuring the condition.
Then apply least privilege. Separate read_customer_record from delete_customer_record; do not create an all-purpose run_admin_action tool. Disable tools that a particular task does not need, and require approval for tools that mutate data or trigger external side effects. The model may choose when to ask for a capability, but engineers still define the capability’s schema, authorization, timeout behavior, retry semantics, and observable output. Agentic coding is more dependable when those responsibilities stay in code.
MCP vs. Subagents vs. Custom Tools: Which Should You Use?
Choose based on the bottleneck. Use MCP when the main agent needs a reusable connection to an external system. Use subagents when the main agent lacks codebase context and independent research can proceed in parallel. Use custom tools when you are building on the SDK and need a controlled function whose behavior, schema, and lifecycle you own. A sophisticated workflow can use all three, but in sequence: subagents first map a large repository; the main agent implements the change; an MCP integration retrieves or updates an external system; a custom tool validates a domain-specific invariant before completion.
Avoid letting every mechanism overlap. Giving a read-only subagent access to privileged production actions would undermine its value as a safe exploration unit. Rebuilding every one-off local helper as a shared MCP server creates operational burden. Stuffing business rules into tool descriptions instead of tested implementations makes outcomes less predictable. The boring design—small tools, explicit permissions, narrow subagent assignments, and a clear external-integration boundary—is the one a team can debug six months later.
Where Cline Fits for Engineers Building Agentic Coding Workflows
Cline describes itself as an open-source coding-agent runtime available in an editor, terminal, and SDK. Its site says the agent can understand and refactor codebases, run bash commands, plan and act with approvals, use MCP servers for databases, APIs, and infrastructure, and register custom tools and lifecycle hooks through the SDK. That makes it relevant whether you want an agent in a daily development environment or a programmable harness for an internal workflow.
For individual developers, Cline says its open-source extension is free, with AI inference charged on a usage basis; users can bring their own API keys or use its provider. Its enterprise offering is custom-priced and adds organization-oriented capabilities such as centralized billing, role-based access control, and SSO. If this article’s architecture appeals to you, Cline provides a concrete place to try the division of labor: parallel repository research, explicit external integrations, and code-defined tools rather than a single opaque prompt.