set_item_config
Update a Jenkins item's configuration by providing its full name and new config XML. Replace existing config with the specified XML data.
Instructions
Set specific item config in Jenkins
Args: fullname: The fullname of the item config_xml: The config XML of the item
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullname | Yes | ||
| config_xml | Yes |
Implementation Reference
- src/mcp_jenkins/server/item.py:46-54 (handler)MCP tool handler for set_item_config — the async function decorated with @mcp.tool(tags=['write']) that receives the context, fullname, and config_xml, then delegates to the Jenkins rest client.
@mcp.tool(tags=['write']) async def set_item_config(ctx: Context, fullname: str, config_xml: str) -> None: """Set specific item config in Jenkins Args: fullname: The fullname of the item config_xml: The config XML of the item """ jenkins(ctx).set_item_config(fullname=fullname, config_xml=config_xml) - src/mcp_jenkins/server/item.py:46-46 (registration)Registration of set_item_config as an MCP tool via the @mcp.tool decorator with tags=['write'].
@mcp.tool(tags=['write']) - The REST client method that performs the actual POST request to Jenkins. Parses the fullname into folder/name, then calls the ITEM_CONFIG endpoint with the config_xml payload and Content-Type: text/xml header.
def set_item_config(self, *, fullname: str, config_xml: str) -> None: """Set item configuration by its fullname. Args: fullname: The full name of the item (e.g., "folder1/folder2/item"). config_xml: The item configuration as an XML string. """ folder, name = self._parse_fullname(fullname) self.request( 'POST', rest_endpoint.ITEM_CONFIG(folder=folder, name=name), headers=self.DEFAULT_HEADERS, data=config_xml, ) - The REST endpoint definition for item config operations (both get and set). Uses the RestEndpoint class which formats the URL with folder and name parameters.
ITEM_CONFIG = RestEndpoint('{folder}job/{name}/config.xml') - Helper that parses a slash-separated fullname into a Jenkins folder path and item name.
def _parse_fullname(self, fullname: str) -> tuple[str, str]: """Parse a fullname into folder URL and short name. Args: fullname: A string representing the full path (e.g., "folder1/folder2/name"). Returns: A tuple containing: - folder: The constructed folder URL (e.g., "job/folder1/job/folder2/"). - name: The last component of the path (e.g., "name"). """ parts = fullname.split('/') name = parts[-1] folder = f'job/{"/job/".join(parts[:-1])}/' if len(parts) > 1 else '' return folder, name