robocop-mcp
MCP server that helps resolve Robocop static code analysis errors and warnings via LLM, providing tools to get reports and run format.
README
Robocop MCP server
Robocop MCP server helps users to resolve their static code analysis errors and warnings with help of an LLM. It has two tools to help resolve Robocop rules:
Get robocop report
Get robocop report tool allows calls robocop check command and
returns one rule violation (maximum 20 from one rule) to LLM.
The rule violation summary also contains default recommendation
how the rule violation can be fixed. User than can accept the
suggested proposal or tell LLM a different way to fix the rule
violation.
The maximum number of rule violations, proposed fix for a rule
and many more things can be configured in the pyproject.toml
file. See Configuration chapter for more details.
Run robocop format
You can also run robocop format tool. Because robocop has complex
commandline syntax, robocop-mcp only support giving file or folder
as an argument for the format command. Rest of the configuration
should be placed in the
robocop configuration file.
The --reruns option is set to 10.
Install
Install with pip:
pip install robocop-mcp
Running robocop-mcp server
running MCP server in VS Code workspace:
- Create a
.vscode/mcp.jsonfile in your workspace. - Add following configuration to the mcp.json file:
{
"servers": {
"robocop-mcp":{
"type": "stdio",
"command": "${workspaceFolder}/.venv/bin/python",
"args": [
"-m",
"robocop_mcp",
],
}
}
}
- Change your CopPilot chat to Agent mode and select suitable model for your use.
- Remember to click start button in the
mcp.jsonfile
For general detail about configuring MCP server in VS Code, see the VS Code documentation
Using robocop-mcp
https://github.com/user-attachments/assets/f446f31f-a91e-4cc1-bae0-6b691469dfba
Configuration
The robocop-mcp server can configured by using
pyproject.toml
file. The robocop-mcp server uses [tool.robocop_mcp] section in the toml file.
To robocop-mcp server see the the toml file, a ROBOCOPMCP_CONFIG_FILE environment
variable must be set. Example in the mcp.json file:
{
"servers": {
"robocop-mcp":{
"type": "stdio",
"command": "python",
"args": [
"-m",
"robocop_mcp",
],
"env": {"ROBOCOPMCP_CONFIG_FILE": "${workspaceFolder}/pyproject.toml"},
}
}
}
Priority of Robocop rules
Some rules are more important to fix than others or perhaps you want to use
certain type of LLM to solve certain type of rule violations. In this case
you can use rule_priority (list) to define which rule are first selected by the
robocop-mcp and given to the LLM model. The rule_priority is a list of
robocop rule id's. You can list all the rules with command:
> robocop list rules
And if one one rules looks like this:
Rule - ARG01 [W]: unused-argument: Keyword argument '{name}' is not used (enabled)
Then rule id is the ARG01.
And example if user wants to prioritize the ARG01 and ARG02 to be fixed first, then
rule_priority would look like this.
[tool.robocop_mcp]
rule_priority = [
"ARG01",
"ARG02"
]
It is also possible to define rule priority by rule name. Example if there is a need to
define ARG01 and ARG02 rules by name, then rule_priority would look like:
[tool.robocop_mcp]
rule_priority = [
"unused-argument",
"argument-overwritten-before-usage"
]
If rule_priority is not defined, robocop-mcp will select take first rule
returned by robocop and use it to find similar rule violations. If no
rules match to rule_priority list, first rule returned by Robocop is used.
Maximum amount violations returned
To not to clutter the LLM context with all the rule violations found from
the test data, by default robocop-mcp will return twenty (20) violations
from robocop. This can be changed by defining different value in the
violation_count (int) setting.
To make robocop-mcp return 30 rule violations:
[tool.robocop_mcp]
violation_count = 30
How many rule violations the robocop-mcp should return depends on the LLM model being used, how verbose the proposed fix is and how long the LLM model context have been in use. It is hard to give good guidance on this subject, because LLM models change at fast pace and there are some many different models available.
Custom fix proposals
Each rule violation contains robocop default rule documentation how
the problem can be addressed. In some cases, this may lead to LLM to wrong
solution or you want to apply custom way to fix the specific rule.
Custom solution can be defined in text file (markdown is recommended,
because it is easy for LLM to understand.) and defining custom rule
files in the pyproject.toml. Each rule where custom fix is defined
is defined as key in toml file and value must point to a text file.
Example if there need to define custom fix for ARG01, create
ARG01.md file, example in a my_rules folder. Then pyproject.toml
should have:
[tool.robocop_mcp]
ARG01 = "my_rules/ARG01.md"
It is also possible to define custom fix proposals by rule name.
Example to provide custom fix proposal for ARG01 by name, then
toml file would look like:
[tool.robocop_mcp]
unused-argument = "my_rules/unused-argument.md"
Ignore rules
The recommended way to ignore rules is to ignore rules in the
robocop tools section in the pyproject.toml. In that case
rules are ignored by Robocop and ignored rules are not visible for the
robocop-mcp serve either.
If there is need to ignore rules only for robocop-mcp, then add
ignore (list) setting to the pyproject.toml file. Example if there is a
need to ignore DOC02, DOC03 and COM04 rules, then pyproject.toml
should have:
[tool.robocop_mcp]
ignore = ["DOC02", "DOC03", "COM04"]
It is also possible to to ignore rules by rule name. If same rules as in above would need to ignored, then ignore list would look like:
[tool.robocop_mcp]
ignore = [
'missing-doc-test-case',
'missing-doc-suite',
'ignored-data'
]
Support separate robocop configuration file
Although robocop-mcp only supports pyproject.toml, the robocop itself
does support multiple different configuration files. If your robocop
configuration is not in pyproject.toml, then the separate configuration
file can be defined in ROBOCOPMCP_ROBOCOP_CONFIG_FILE environment
variable. Example mcp.json:
{
"servers": {
"robocop-mcp":{
"type": "stdio",
"command": "${workspaceFolder}/.venv/bin/python",
"args": [
"-m",
"robocop_mcp",
],
"env": {
"ROBOCOPMCP_CONFIG_FILE": "${workspaceFolder}/pyproject.toml",
"ROBOCOPMCP_ROBOCOP_CONFIG_FILE": "${workspaceFolder}/robocop.toml",
}
}
}
}
Robocop reruns
It is possible to configure how robocop format --reruns command line argument
is set. This is controlled in the pyproject.toml file by reruns (int) setting.
By default value is set to ten, but the set it to two add the following to
pyproject.toml file:
[tool.robocop]
reruns = 2
Contributing fix instructions for rule
Users can contribute their instructions to for rule fixes in the repository. This
is explained in the
CONTRIBUTING.md
file. If there is not fix, either from robocop-mcp or by user defined fixes, then
robocop documentation is used as fix instruction to LLM. User can always write
their own fix explanation in the prompt, but if that is not one off, then it is
easier to define user defined rule fix in a file or contribute a fix to the
robocop-mcp project.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。