Customising tools for your hosted Patchworks MCP server
Introduction
The hosted Patchworks MCP server includes a set of default tools that are ready to use. You can't edit these, but you can add your own.
To do this, you create a draft server deployment and then write Python directly in the editor. When the draft is deployed, your custom tools become available alongside the default set.
You need a working knowledge of Python, Pydantic, the FastMCP framework, and the Patchworks API to add MCP tools.
Need to know
Tools can only be added or updated in a
draftserver deployment. You can create adraftfrom an existingdeployedserver or from aninactive(i.e. previouslydeployed) version.Any new tools must follow a defined pattern.
Code for built-in tools is not exposed - you cannot edit or remove default tools.
Default template
When you create a new MCP server, a default template is provided:
We break this file down in the following sections:
Import libraries
Loads required libraries, including type hints, Pydantic for argument validation, the MCP context, HTTP requests, and logging utilities.
Set up logging
Configures a logger so tools can output diagnostic messages during execution.
Built-in tools reference
A commented list of the built-in tools. This is just reference information, so you can see what's already available.
Environment
A commented summary explaining what's available in the environment (pw, get_token_from_context, decorators, etc.).
Tool pattern
A commented template showing the required three-part pattern for adding a tool: argument model, tool definition, and registry:
Use this pattern for any tools that you want to add.
Core helper
A reusable function that handles making authenticated requests to the Patchworks Core API. It reads the API base URL from the environment, attaches auth headers, makes the request, handles errors, and returns the JSON response. This helper is used by every tool.
Example tool (get all caches)
A working example (get all caches) showing the three-part pattern in practice.
Where do I add the next tool?
To extend the default specification, add your next tool right after the last. See line 138 onwards in the full example below, where we've added a tool to get connectors:
Editing an MCP server draft deployment
As noted previously, to add your own tools to the Patchworks MCP server, you must work with a draft deployment.
Access your MCP server deployments
Select the settings option (at the bottom of the navigation menu):

Then select the MCP servers option:

Create a draft deployment (if not already present)
If your server deployments list already includes a draft entry, you can skip this step. Otherwise, you can create a draft using ONE of the methods below:
If a deployed or inactive entry IS present:
Create a draft from it
This creates a new draft entry, leaving any existing deployed version in place (so your AI assistant(s) can continue to access the hosted Patchworks MCP server while you make changes).
Click the ellipsis icon for the required entry:

Then select the create draft from option:

Undeploy the current deployment
If a deployed entry is present, you can undeploy it. This changes the version from deployed to draft, ready for editing. However, it's important to note that your AI assistant(s) cannot access the hosted Patchworks MCP server when it is undeployed.
Click the ellipsis icon for the required entry:

Then select the undeploy option:

If a deployed or inactive entry IS NOT present:
Create a new server deployment, then undeploy it
Follow instructions to deploy a hosted Patchworks MCP server for the first time, then immediately undeploy it (see above) to change the deployed status to draft).
If a deployed entry IS present, but you want to start again from scratch:
Create a new server deployment, then undeploy it
Follow instructions to undeploy the
deployedversion, setting it back todraft.Follow instructions to deploy a hosted Patchworks MCP server for the first time, then immediately undeploy it to change the
deployedstatus todraft).
Edit the draft entry
Click the ellipsis icon for the draft entry, then select the edit option. For example:

Make required updates
Use the code editor to add/adjust tools:

Save or save & deploy the draft
If you want to save your changes but not deploy them yet, click the save button:

Your changes are saved and the draft status does not change.
Keep in mind that you can't test your changes until the draft is deployed.
If you're ready to deploy the draft version, click the save and deploy button:

The draft status changes to deployed. If there was already a deployed version, this becomes inactive.
Once your changes are deployed, you can test the updated tools via the MCP servers page and/or your AI assistant.
Deploying an updated draft does not affect existing connections with AI assistants - these will pick up the new/changed tools when requests are made.
Last updated
Was this helpful?