Skip to main content

MCP server for helping user to resolve Robot Framework code issues detected by Robocop.

Project description

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.

Install

Install with pip: pip install robocop-mcp

Running robocop-mcp server

running MCP server in VS Code workspace:

  1. Create a .vscode/mcp.json file in your workspace.
  2. Add following configuration to the mcp.json file:
{
    "servers": {
        "robocop-mcp":{
            "type": "stdio",
            "command": "${workspaceFolder}/.venv/bin/python",
            "args": [
                "-m",
                "robocop_mcp",
            ],

        }
    }
}
  1. Change your CopPilot chat to Agent mode and select suitable model for your use.
  2. Remember to click start button in the mcp.json file

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"
]

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"

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"]

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",
            }
        }
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robocop_mcp-1.5.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robocop_mcp-1.5.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file robocop_mcp-1.5.0.tar.gz.

File metadata

  • Download URL: robocop_mcp-1.5.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robocop_mcp-1.5.0.tar.gz
Algorithm Hash digest
SHA256 a444480ecaf3ab0c0da698a6738b93aebde5d897ada7b2d49759ab5eb5a928c4
MD5 a24f03629935c801f9575be277d15e87
BLAKE2b-256 b075fa0ce1d90e0258f3b8c2bf3e7b454d2d8e658cb9355c110ed9f9f357fa35

See more details on using hashes here.

File details

Details for the file robocop_mcp-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: robocop_mcp-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for robocop_mcp-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0dca3f987d09614beccaf096dbda5ebc7d5bc87d39713c487b5190aa1929d9f
MD5 8ff86f5a83d0ec866c9d11521648e40e
BLAKE2b-256 88af255b29ba454d99a4c92fa36572e9e00876549592e228d38fc58b6e30ed09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page