> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-xdr-5.x/configure-cortex-xdr/configure-and-deploy-cortex-xdr/cortex-mcp-server/create-custom-cortex-mcp-server-tools.md).

# Create custom Cortex MCP server tools

You can build your own tools using OpenAPI or Python to manage cases, handle issues, and conduct investigations. More detailed information can be found in the README file located in the `src/usecase` directory. Tools are based on Cortex API endpoints.

To view the Cortex XDR API documentation, see [Cortex XDR APIs](broken://spaces/ypkjKiIHM5itLDXVF5Ac/pages/0n5uxGlyGj6EGNDEecb7).

{% hint style="info" %}

### Note

Any new or updated components provided by Cortex are automatically downloaded into the builtin\_components folder. During each update, the folder is fully replaced and all existing contents are recreated. Do not add custom tools to this directory, as it is managed entirely by Cortex and is overwritten at every update.
{% endhint %}

### Create an OpenAPI tool

1. Create a YAML file in the `/custom_components/openapi` directory with the name of the MCP component. For example: `custom_cortex_component.yaml`.
2. Base your custom OpenAPI component on the Cortex API documentation structure for a specific endpoint. We recommend viewing the built-in tools, located at `/builtin_components/openapi`, as a reference.
3. After you define the OpenAPI specification, the Cortex MCP server collects it automatically and it is ready for use.
4. Test your new MCP component by running the Cortex MCP server and writing a prompt that uses your new component.

### Create a Python tool

We recommend using Python for more complex MCP components that require custom logic. MCP components in Python are defined in a module.

1. Create a new Python file in the `/custom_components` directory.
2. Define a class that inherits from the `BaseModule` class with the required methods. We recommend viewing the built-in modules, located at `/builtin_components`, as a reference.
3. After you define a class, the Cortex MCP server collects it automatically and it is ready for use.
4. Test your new MCP component by adding an end-to-end test in the `tests/e2e` directory or run the MCP server and write a prompt that uses your new component.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-xdr-5.x/configure-cortex-xdr/configure-and-deploy-cortex-xdr/cortex-mcp-server/create-custom-cortex-mcp-server-tools.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
