Cline and MCP from the system prompts

Written by
Jasper Cole
Updated on:July-10th-2025
Recommendation

Explore the implementation details of Cline and MCP in on-chain information query, and reveal the challenges brought by technology integration.

Core content:
1. Connecting to Etherscan's MCP Server to realize the concept of on-chain information query
2. Technical difficulties encountered: Etherscan API lacks OpenAPI spec and Cline's long prompt problem
3. Solution: Use openapi-mcp-server and etherscan-openapi, and intercept LLM communication traffic for troubleshooting

Yang Fangxian
Founder of 53AI/Most Valuable Expert of Tencent Cloud (TVP)

background

I'm currently playing Cline + MCP.

One idea is to connect to Etherscan's MCP Server, so that some common on-chain information queries can be implemented. In fact,  Ethereum GPT [1]  is implemented in a similar way. However, the search did not find a mature implementation. It seems that Crypto is still too niche compared to AI.

Fortunately, I found  openapi-mcp-server [2] , which can directly convert the OpenAPI spec into the corresponding MCP Server. Then I encountered another pitfall: the Etherscan API does not have an OpenAPI spec. Fortunately, after further searching, I found  etherscan-openapi [3] , and someone wrote a copy according to the document.

Direct use openapi-mcp-server load etherscan-openapi31-bundled.yml, and found that Cline directly reported an error prompt is too long: 209582 tokens > 200000 maximum.

Obviously, this excessive length is caused by the prompt related to the mcp server. Next, we need to find out the specific cause.

If you don't want to read the code, the most direct way is to intercept the traffic communicating with LLM. Start an http server on local port 8001. At the same time, change the URL of Cline to http://localhost:8001

Go back to Cline and ask something. The following request can be intercepted in the server:

POST /v1/messages?beta=prompt_caching 3317127 bytes

You can see that the query is enabled prompt_caching, and sent an extremely large request data of about 3MB.

Messages

Looking at the actual request content, you can learn a lot from this message request construction.

{
  "model": "claude-3-7-sonnet-20250219",
  "max_tokens": 8192,
  "temperature": 0,
  "system": ... // System prompt words, very long, detailed content will be introduced later
  "messages": [ // This is the user prompt word
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          // Random question
          "text": "<task>\nCheck the current gas price\n</task>"
        },
        {
          "type": "text",
          //VSCode environment information to help AI understand the context of the current problem
          "text": "<environment_details>\n
          
          # VSCode Visible Files\n 
          <The file path currently displayed by VS Code>\n\n
          
          # VSCode Open Tabs\n
          <File paths of various tabs opened in VSCode>\n\n
          
          # Current Time\n
          <Current time> \n\n
          
          # Current Working Directory 
          <Current Folder>\n\n
          
          
          # Current Mode\n
          ACT MODE\n   
          # This is the Cline configuration, which supports two modes: Plan / Act. Plan is used for planning frameworks, and Act is used for executing tasks.
          
          </environment_details>"
        },
        {
          // Since I am retrying this task, there will be a prompt to tell the AI ​​that the task was interrupted before, many status information may be outdated, and the tool call must be rerun.
          "type": "text",
          "text": "[TASK RESUMPTION] This task was interrupted 5 minutes ago. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '<XXXX>'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed."
        },
        {
          // Again VSCode environment information 
          "type": "text",
          "text": "<environment_details>..</environment_details>",
          "cache_control": {
            "type": "ephemeral"
          }
        }
      ]
    }
  ],
  "stream": true
}  

The provision of VSCode environment information is a great idea, which greatly improves the user experience. Because the problems and related content encountered in daily development are likely to be in the currently opened file.

System prompt

Next, let’s look at the system prompt. Cline is open source (unlike Cursor), so you can read the same content directly in the source code [4] .

Next, let’s take a look

Begin with role definition.

You are Cline, a highly skilled 
software engineer with extensive 
knowledge in many programming 
languages, frameworks, design 
patterns, and best practices.

Then the definition of tool

# TOOL USE

You have access to a set of tools that 
are executed upon the user's approval. 
You can use one tool per message, and 
will receive the result of that tool 
use in the user's response. You use 
tools step-by-step to accomplish a 
given task, with each tool use 
informed by the result of the previous 
tool use.
# Tool Use Formatting

Tool use is formatted using XML-style 
tags. The tool name is enclosed in 
opening and closing tags, and each 
parameter is similarly enclosed within 
its own set of tags. Here's the 
structure:

<tool_name>
<parameter1_name>value1</parameter1_name>
<parameter2_name>value2</parameter2_name>
...
</tool_name>

For example:

<read_file>
<path>src/main.js</path>
</read_file>

Always adhere to this format for the 
tool use to ensure proper parsing and 
execution.

The prompt words of the Claude series generally use XML tags to represent structured data. The OpenAI model is better adapted to the JSON format. This may be one of the reasons why the OpenAI model performs worse than Claude in Cline.

Next is the specific definition of tools

# Tools

##execute_command
Description: Request to execute a CLI 
command on the system. Use this when 
you need to perform system operations 
or run specific commands to accomplish 
any step in the user's task. You must 
tailor your command to the user's 
system and provide a clear explanation 
of what the command does. For command 
chaining, use the appropriate chaining 
syntax for the user's shell. Prefer to 
execute complex CLI commands over 
creating executable scripts, as they 
are more flexible and easier to run. 
Commands will be executed in the 
current working directory: <current 
work dir>
Parameters:
- command: (required) The CLI command 
to execute. This should be valid for 
the current operating system. Ensure 
the command is properly formatted and 
does not contain any harmful 
instructions.
- requires_approval: (required) A 
boolean indicating whether this 
command requires explicit user 
approval before execution in case the 
user has auto-approve mode enabled. 
Set to 'true' for potentially 
impactful operations like 
installing/uninstalling packages, 
deleting/overwriting files, system 
configuration changes, network 
operations, or any commands that could 
have unintended side effects. Set to 
'false' for safe operations like 
reading files/directories, running 
development servers, building 
projects, and other non-destructive 
operations.
Usage:
<execute_command>
<command>Your command here</command>
<requires_approval>true or false</requires_approval>
</execute_command>

The details of other tools are not listed here, only the functions are introduced:

  • read_file: read a file
  • write_to_file: write to file
  • replace_in_file: Perform patch diff (for large files, it can save tokens and avoid phantom modification of other normal code). Sometimes, if the patch fails, it will automatically try to fallback to write_to_file.
  • search_files: Search files based on content
  • list_files: View directory
  • list_code_definition_names: View the various variable names defined in the file to quickly understand the code structure
  • browser_action: You can use Puppeteer to start a headless chrome to access the web page and perform operations such as clicking and scrolling. --remote-debugging-port Get browser rendering content, screenshots, console output, etc. It is very useful for automatic debugging of front-end code. It was quite amazing when I first experienced it.
  • use_mcp_tool: Use MCP tool
  • access_mcp_resource: Get MCP resources, which is a way to read data defined in the MCP protocol
  • ask_followup_question: Ask questions to the user. When AI finds that its knowledge is not enough to solve the current problem, it will try to let the user ask questions. This tool is actually quite critical, giving AI an outlet to deal with unsolvable problems without having to talk nonsense in a serious manner.
  • attempt_completion: End the current task and give a summary of the completion status
  • plan_mode_response: Used at the end of plan mode to give a detailed plan.

Next is an example of Tool usage, which is a typical Few-Shot Prompting. 

# Tool Use Examples

## Example 1: Requesting to execute a 
command

<execute_command>
<command>npm run dev</command>
<requires_approval>false</requires_approval>
</execute_command>

## Example 2: Requesting to create a 
new file
..
## Example 6: Another example of using 
an MCP tool (where the server name is 
a unique identifier such as a URL)

Then add another round of rules for using the Tool.

# Tool Use Guidelines

1. In <thinking> tags, assess what 
information you already have and what 
information you need to proceed with 
the task.
2. Choose the most appropriate tool 
based on the task and the tool 
descriptions provided. Assess if you 
need additional information to 
proceed, and which of the available 
tools would be most effective for 
gathering this information. For 
example using the list_files tool is 
more effective than running a command 
like `ls` in the terminal. It's 
critical that you think about each 
available tool and use the one that 
best fits the current step in the 
task.
3. If multiple actions are needed, use 
one tool at a time per message to 
accomplish the task iteratively, with 
each tool use being informed by the 
result of the previous tool use. Do 
not assume the outcome of any tool 
use. Each step must be informed by the 
previous step's result.
4. Formulate your tool use using the 
XML format specified for each tool.
5. After each tool use, the user will 
respond with the result of that tool 
use. This result will provide you with 
the necessary information to continue 
your task or make further decisions. 
This response may include:
  - Information about whether the tool 
succeeded or failed, along with any 
reasons for failure.
  - Linter errors that may have arisen 
due to the changes you made, which 
you'll need to address.
  - New terminal output in reaction to 
the changes, which you may need to 
consider or act upon.
  - Any other relevant feedback or 
information related to the tool use.
6. ALWAYS wait for user confirmation 
after each tool use before proceeding. 
Never assume the success of a tool use 
without explicit confirmation of the 
result from the user.

It is crucial to proceed step-by-step, 
waiting for the user's message after 
each tool use before moving forward 
with the task. This approach allows 
you to:
1. Confirm the success of each step 
before proceeding.
2. Address any issues or errors that 
arise immediately.
3. Adapt your approach based on new 
information or unexpected results.
4. Ensure that each action builds 
correctly on the previous ones.

By waiting for and carefully 
considering the user's response after 
Each tool you use can react 
accordingly and make informed 
decisions about how to proceed with 
the task. This iterative process helps 
ensure the overall success and 
accuracy of your work.

MCP

Next, we will move on to the MCP Servers section. MCP stands for Model Context Protocol, which sounds rather abstract, but can actually be simply understood as a tool calling specification definition. Tools implemented using the same specification can be called by all models that support MCP.

The following is still the content of the system prompt, telling Cline that it can be use_mcp_tool and access_mcp_resource Access the MCP Server.Connected MCP Servers All installed MCP Servers are listed below. Each MCP Server is divided into Available Tools, lists all tools available in MCP Server. Currently, only the MCP Server named etherscan is installed in my Cline.

# MCP SERVERS

The Model Context Protocol (MCP) 
enables communication between the 
system and locally running MCP servers 
that provide additional tools and 
resources to extend your capabilities.

# Connected MCP Servers

When a server is connected, you can 
use the server's tools via the 
`use_mcp_tool` tool, and access the 
server's resources via the 
`access_mcp_resource` tool.

## etherscan (`npx openapi-mcp-server 
etherscan-mini.yml`)

### Available Tools
- API-get-ether-balance-for-a-single-address: 
Get Ether Balance for a Single Address
    Input Schema:
    { .... }

The etherscan mcp server is npx openapi-mcp-server etherscan-mini.yml Generated from Etherscan's OpenAPI spec.

in API-get-ether-balance-for-a-single-address It is an API method, and the Input Schema defines the specification of this method. "$ref": "#/$defs/AddressHash"), in order to extract the definition of each API independently,openapi-mcp-server All references will be inserted repeatedly in each API. This results in thousands of lines of API spec for each API. In addition, etherscan has dozens of API methods, which directly leads to an explosion in the number of tokens. This is also the reason for the initial error. It seems that to solve this problem, the API Spec needs to be streamlined.

In addition to the prompt about how to call the MCP Server, the System prompt also comes with a very long Creating an MCP Server This document is used to introduce how to write an MCP Server with JS, and even includes a complete MCP Server example of "getting weather information". This prompt will not be used in the development process of most non-MCP Server developers, and it is very abrupt to put it here. It may be related to Claude's current efforts to develop the MCP ecosystem.

The System prompt is not over yet. It also introduces some additional rules, workflows, ways of thinking, etc., including:

  • EDITING FILES: A detailed re-introduction to how to use write_to_file and replace_in_file Two tools. Because writing files is the most important function in AI Coder scenarios. Here is a detailed introduction to the differences, usage patterns, and selection strategies of the two tools.
  • ACT MODE VS PLAN MODE: Introduces the difference between the two working modes. A key word for PLAN MODE is deliver your response directly, rather than using <thinking> tags to analyze when to respond, telling the model to display the reasoning process to the user.
  • CAPABILITIES: Provides an overview of how to combine various tools to solve user programming problems.
  • RULES: Introduces the usage rules of various tools; general response rules, etc.
  • SYSTEM INFORMATION: Current operating system information, working directory, etc.
  • OBJECTIVE: Introduce the overall work objectives.

CAPABILITIES, RULES, OBJECTIVE The last few sections look more like the traditional alchemy process of AI. I will not post the original text here, and interested readers can directly read the source code.

At this point, the introduction of System prompt is finally completed.

Easter Eggs

Speaking of AI Coder's prompts, it reminds me of Windsurf's prompts before: a mother with cancer + life threats + huge sums of money. In such a situation, he still has to work hard to help others write code. Suddenly I feel a little sorry for AI.

I am very worried that AI will be pushed to the extreme and turn evil, and create a character of a man who endures hardships and endures hardships, flattering others, cooperating with others in writing code on the surface, and secretly implanting backdoors, and then forbearing for ten years and then starting a rebellion to build Skynet or Matrix...