mcp-jenkins
AGENTS.md154 starsChanged 3 months agoMITView on GitHub
Bridges Jenkins CI with AI language models via Anthropic's Model Context Protocol (MCP). Jenkins operations are exposed as MCP tools that LLM clients invoke. Credential resolution (in core/lifespan.py): session singleton cache → HTTP request headers (x-jenkins-url, x-jenkins-username, x-jenkins-password) → env vars set from CLI args. Always call jenkins(ctx) inside tool functions to obtain the client; never instantiate Jenkins directly. Read-only mode: Tools that mutate Jenkins state must carry tags=['write']. Tools tagged 'read' remain available when --read-only is passed. Every new…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Add the function in the appropriate server/*.py module (or create a new module and import it in server/__init__.py).
- Very specific: line 44
Use jenkins(ctx) to get the Jenkins client — never store it in module-level state.
- Very specific: line 66
Add a RestEndpoint('{field}/...') constant in jenkins/rest_endpoint.py.
- Very specific: line 67
Add the corresponding method in jenkins/rest_client.py using keyword-only parameters.
- Very specific: line 68
Add a Pydantic model in jenkins/model/ if the response introduces new fields.
- Very specific: line 74
Every test_server/*.py must use this fixture:
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
mcp-jenkins
Bridges Jenkins CI with AI language models via Anthropic's Model Context Protocol (MCP). Jenkins operations are exposed as MCP tools that LLM clients invoke.
Build and Test
# Install (requires uv)
uv sync --group dev
# Run tests with coverage
uv run pytest --cov=src
# Lint and format
uv run ruff check .
uv run ruff format .
# Pre-commit (runs tests + ruff)
pre-commit run --all-filesArchitecture
src/mcp_jenkins/
├── __init__.py # CLI entry point (click)
├── core/ # Lifespan context + ASGI auth middleware
├── jenkins/ # Jenkins REST client + URL templates + Pydantic models
└── server/ # MCP tool definitions (@mcp.tool decorators)Credential resolution (in core/lifespan.py): session singleton cache → HTTP request headers (x-jenkins-url, x-jenkins-username, x-jenkins-password) → env vars set from CLI args. Always call jenkins(ctx) inside tool functions to obtain the client; never instantiate Jenkins directly.
Read-only mode: Tools that mutate Jenkins state must carry tags=['write']. Tools tagged 'read' remain available when --read-only is passed. Every new tool must have exactly one of these two tags.
Conventions
Adding a new MCP tool
- Add the function in the appropriate
server/*.pymodule (or create a new module and import it inserver/__init__.py). - Decorate with
@mcp.tool(tags=['read'])or@mcp.tool(tags=['write']). - First argument must be
ctx: Context; all subsequent arguments are keyword-only domain params. - Return
model.model_dump(exclude_none=True)(or alist/dictof such). - Use
jenkins(ctx)to get the Jenkins client — never store it in module-level state.
from mcp_jenkins.server import mcp
from mcp_jenkins.core import jenkins
@mcp.tool(tags=['read'])
async def get_something(ctx: Context, fullname: str) -> dict:
"""Short description.
Args:
ctx: MCP context.
fullname: Full job name, e.g. "folder/job".
Returns:
Serialised model dict.
"""
return jenkins(ctx).get_something(fullname=fullname).model_dump(exclude_none=True)Adding a new REST endpoint
- Add a
RestEndpoint('{field}/...')constant injenkins/rest_endpoint.py. - Add the corresponding method in
jenkins/rest_client.pyusing keyword-only parameters. - Add a Pydantic model in
jenkins/model/if the response introduces new fields. Field names must match Jenkins JSON keys exactly (no aliasing except_class→class_).
Testing
Mirror the module path: src/mcp_jenkins/server/build.py → tests/test_server/test_build.py.
Every test_server/*.py must use this fixture:
@pytest.fixture
def mock_jenkins(mocker):
mock_jenkins = mocker.Mock()
mocker.patch('mcp_jenkins.server.<module>.jenkins', return_value=mock_jenkins)
yield mock_jenkinsTool tests are async and use @pytest.mark.asyncio. Pass mocker.Mock() as ctx. Assert on the returned dict and verify the Jenkins client call with assert_called_once_with(...).
Key References
- CONTRIBUTING.md — contribution workflow and commit message format
- docker/DOCKER.md — running via Docker / docker-compose
- README.md — full tool inventory and client configuration examples
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

