Adding custom tools to the managed MCP server

Watsonx.data intelligence includes a preconfigured MCP server with built-in tools that work seamlessly with the product. You can extend the set of tools by uploading custom MCP tools.

These tools are then made available along with the built-in tools and users can access all of them from a single interface.

Who needs to complete this task?

Instance administrator To add custom MCP tools to the MCP server in watsonx.data intelligence, you must be an instance administrator.

Procedure

To add custom MCP tools:

  1. In your local file system, create a directory structure that is similar to the app/services directory structures in the https://github.com/IBM/data-intelligence-mcp-server repository.
    Create a new directory with at least one subdirectory and 3 files:
    1. An __init__.py file in the new directory
    2. A tools subdirectory
    3. An __init__.py file in the tools subdirectory
    cat << EOF > __init__.py
    EOF
    
    mkdir tools
    
    cat << EOF > tools/__init__.py
    EOF
  2. For each new MCP tool, create a new .py file in the tools subdirectory.
    The tool configuration must include the custom tag like in the following example:
    cat << EOF >> ./tools/example_tool.py
    from typing import Any
    
    from app.core.registry import service_registry
    from app.shared.logging import LOGGER
    
    
    @service_registry.tool(
        name="test_tool",
        description="Example custom tool. This demonstrates the structure for custom tools.",
        tags={"custom"}
    )
    async def test_tool(
        resource_id: str,
        action: str = "query"
    ) -> dict[str, Any]:
        """
        Example custom tool 
        Args:
            resource_id: The ID of the resource to operate on
            action: The action to perform (query, update, delete, etc.)
        
        Returns:
            Dictionary containing the operation result
        """
        LOGGER.info(f"Executing custom tool for resource: {resource_id}, action: {action}")
        
        result = {
                "status": "success",
                "resource_id": resource_id,
                "action": action,
                "message": "This is an example custom tool. Replace with actual implementation."
            }
            
        LOGGER.info(f"Custom tool completed successfully for resource: {resource_id}")
        return result
    EOF
  3. Synchronize the files with the semantic-agent-service pod and disable tool filtering.
    1. Copy the files:
      POD_NAME=`oc get pods | grep semantic-agent | awk '{print $1}'`
      oc rsync ./ $POD_NAME:/sal/custom-tools
    2. Verify that all files were copied:
      oc rsh deploy/semantic-agent-service  ls -R /sal/custom-tools
    3. Disable tool filtering so that custom tools can be loaded:
      oc set env deploy/semantic-agent-service enable_mcp_tool_filtering=false

What to do next

Check in your MCP client that the new tools are visible.