trustgraph/docs/cli/tg-delete-mcp-tool.md
cybermaggedon 89be656990
Release/v1.2 (#457)
* Bump setup.py versions for 1.1

* PoC MCP server (#419)

* Very initial MCP server PoC for TrustGraph

* Put service on port 8000

* Add MCP container and packages to buildout

* Update docs for API/CLI changes in 1.0 (#421)

* Update some API basics for the 0.23/1.0 API change

* Add MCP container push (#425)

* Add command args to the MCP server (#426)

* Host and port parameters

* Added websocket arg

* More docs

* MCP client support (#427)

- MCP client service
- Tool request/response schema
- API gateway support for mcp-tool
- Message translation for tool request & response
- Make mcp-tool using configuration service for information
  about where the MCP services are.

* Feature/react call mcp (#428)

Key Features

  - MCP Tool Integration: Added core MCP tool support with ToolClientSpec and ToolClient classes
  - API Enhancement: New mcp_tool method for flow-specific tool invocation
  - CLI Tooling: New tg-invoke-mcp-tool command for testing MCP integration
  - React Agent Enhancement: Fixed and improved multi-tool invocation capabilities
  - Tool Management: Enhanced CLI for tool configuration and management

Changes

  - Added MCP tool invocation to API with flow-specific integration
  - Implemented ToolClientSpec and ToolClient for tool call handling
  - Updated agent-manager-react to invoke MCP tools with configurable types
  - Enhanced CLI with new commands and improved help text
  - Added comprehensive documentation for new CLI commands
  - Improved tool configuration management

Testing

  - Added tg-invoke-mcp-tool CLI command for isolated MCP integration testing
  - Enhanced agent capability to invoke multiple tools simultaneously

* Test suite executed from CI pipeline (#433)

* Test strategy & test cases

* Unit tests

* Integration tests

* Extending test coverage (#434)

* Contract tests

* Testing embeedings

* Agent unit tests

* Knowledge pipeline tests

* Turn on contract tests

* Increase storage test coverage (#435)

* Fixing storage and adding tests

* PR pipeline only runs quick tests

* Empty configuration is returned as empty list, previously was not in response (#436)

* Update config util to take files as well as command-line text (#437)

* Updated CLI invocation and config model for tools and mcp (#438)

* Updated CLI invocation and config model for tools and mcp

* CLI anomalies

* Tweaked the MCP tool implementation for new model

* Update agent implementation to match the new model

* Fix agent tools, now all tested

* Fixed integration tests

* Fix MCP delete tool params

* Update Python deps to 1.2

* Update to enable knowledge extraction using the agent framework (#439)

* Implement KG extraction agent (kg-extract-agent)

* Using ReAct framework (agent-manager-react)
 
* ReAct manager had an issue when emitting JSON, which conflicts which ReAct manager's own JSON messages, so refactored ReAct manager to use traditional ReAct messages, non-JSON structure.
 
* Minor refactor to take the prompt template client out of prompt-template so it can be more readily used by other modules. kg-extract-agent uses this framework.

* Migrate from setup.py to pyproject.toml (#440)

* Converted setup.py to pyproject.toml

* Modern package infrastructure as recommended by py docs

* Install missing build deps (#441)

* Install missing build deps (#442)

* Implement logging strategy (#444)

* Logging strategy and convert all prints() to logging invocations

* Fix/startup failure (#445)

* Fix loggin startup problems

* Fix logging startup problems (#446)

* Fix logging startup problems (#447)

* Fixed Mistral OCR to use current API (#448)

* Fixed Mistral OCR to use current API

* Added PDF decoder tests

* Fix Mistral OCR ident to be standard pdf-decoder (#450)

* Fix Mistral OCR ident to be standard pdf-decoder

* Correct test

* Schema structure refactor (#451)

* Write schema refactor spec

* Implemented schema refactor spec

* Structure data mvp (#452)

* Structured data tech spec

* Architecture principles

* New schemas

* Updated schemas and specs

* Object extractor

* Add .coveragerc

* New tests

* Cassandra object storage

* Trying to object extraction working, issues exist

* Validate librarian collection (#453)

* Fix token chunker, broken API invocation (#454)

* Fix token chunker, broken API invocation (#455)

* Knowledge load utility CLI (#456)

* Knowledge loader

* More tests
2025-08-18 20:56:09 +01:00

9.1 KiB

tg-delete-mcp-tool

Synopsis

tg-delete-mcp-tool [OPTIONS] --name NAME

Description

The tg-delete-mcp-tool command deletes MCP (Model Control Protocol) tools from the TrustGraph system. It removes MCP tool configurations by name from the 'mcp' configuration group. Once deleted, MCP tools are no longer available for agent use.

This command is useful for:

  • Removing obsolete or deprecated MCP tools
  • Cleaning up MCP tool configurations
  • Managing MCP tool registry maintenance
  • Updating MCP tool deployments by removing old versions

The command removes MCP tool configurations from the 'mcp' configuration group in the TrustGraph API.

Options

  • -u, --api-url URL

    • TrustGraph API URL for configuration management
    • Default: http://localhost:8088/ (or TRUSTGRAPH_URL environment variable)
    • Should point to a running TrustGraph API instance
  • --name NAME

    • Required. MCP tool name to delete
    • Must match an existing MCP tool name in the registry
    • MCP tool will be completely removed from the system
  • -h, --help

    • Show help message and exit

Examples

Basic MCP Tool Deletion

Delete a weather MCP tool:

tg-delete-mcp-tool --name weather

Calculator MCP Tool Deletion

Delete a calculator MCP tool:

tg-delete-mcp-tool --name calculator

Custom API URL

Delete an MCP tool from a specific TrustGraph instance:

tg-delete-mcp-tool --api-url http://trustgraph.example.com:8088/ --name custom-mcp

Batch MCP Tool Deletion

Delete multiple MCP tools in a script:

#!/bin/bash
# Delete obsolete MCP tools
tg-delete-mcp-tool --name old-search
tg-delete-mcp-tool --name deprecated-calc
tg-delete-mcp-tool --name unused-mcp

Conditional Deletion

Delete an MCP tool only if it exists:

#!/bin/bash
# Check if MCP tool exists before deletion
if tg-show-mcp-tools | grep -q "test-mcp"; then
    tg-delete-mcp-tool --name test-mcp
    echo "MCP tool deleted"
else
    echo "MCP tool not found"
fi

Deletion Process

The deletion process involves:

  1. Existence Check: Verify the MCP tool exists in the configuration
  2. Configuration Removal: Delete the MCP tool configuration from the 'mcp' group

The command performs validation before deletion to ensure the tool exists.

Error Handling

The command handles various error conditions:

  • Tool not found: If the specified MCP tool name doesn't exist
  • API connection errors: If the TrustGraph API is unavailable
  • Configuration errors: If the MCP tool configuration cannot be removed

Common error scenarios:

# MCP tool not found
tg-delete-mcp-tool --name nonexistent-mcp
# Output: MCP tool 'nonexistent-mcp' not found.

# Missing required field
tg-delete-mcp-tool
# Output: Exception: Must specify --name for MCP tool to delete

# API connection error
tg-delete-mcp-tool --api-url http://invalid-host:8088/ --name tool1
# Output: Exception: [Connection error details]

Verification

The command provides feedback on the deletion process:

  • Success: MCP tool 'tool-name' deleted successfully.
  • Not found: MCP tool 'tool-name' not found.
  • Error: Error deleting MCP tool 'tool-name': [error details]

Advanced Usage

Safe Deletion with Verification

Verify MCP tool exists before deletion:

#!/bin/bash
MCP_NAME="weather"

# Check if MCP tool exists
if tg-show-mcp-tools | grep -q "^$MCP_NAME"; then
    echo "Deleting MCP tool: $MCP_NAME"
    tg-delete-mcp-tool --name "$MCP_NAME"
    
    # Verify deletion
    if ! tg-show-mcp-tools | grep -q "^$MCP_NAME"; then
        echo "MCP tool successfully deleted"
    else
        echo "MCP tool deletion failed"
    fi
else
    echo "MCP tool $MCP_NAME not found"
fi

Backup Before Deletion

Backup MCP tool configuration before deletion:

#!/bin/bash
MCP_NAME="important-mcp"

# Export MCP tool configuration
echo "Backing up MCP tool configuration..."
tg-show-mcp-tools | grep -A 10 "^$MCP_NAME" > "${MCP_NAME}_backup.txt"

# Delete MCP tool
echo "Deleting MCP tool..."
tg-delete-mcp-tool --name "$MCP_NAME"

echo "MCP tool deleted, backup saved to ${MCP_NAME}_backup.txt"

Cleanup Script

Clean up multiple MCP tools based on patterns:

#!/bin/bash
# Delete all test MCP tools
echo "Cleaning up test MCP tools..."

# Get list of test MCP tools
TEST_MCPS=$(tg-show-mcp-tools | grep "^test-" | cut -d: -f1)

for mcp in $TEST_MCPS; do
    echo "Deleting $mcp..."
    tg-delete-mcp-tool --name "$mcp"
done

echo "Cleanup complete"

Environment-Specific Deletion

Delete MCP tools from specific environments:

#!/bin/bash
# Delete development MCP tools from production
export TRUSTGRAPH_URL="http://prod.trustgraph.com:8088/"

DEV_MCPS=("dev-mcp" "debug-mcp" "test-helper")

for mcp in "${DEV_MCPS[@]}"; do
    echo "Removing development MCP tool: $mcp"
    tg-delete-mcp-tool --name "$mcp"
done

MCP Service Shutdown

Remove MCP tools when services are decommissioned:

#!/bin/bash
# Remove MCP tools for decommissioned service
SERVICE_NAME="old-service"

# Find MCP tools for this service
MCP_TOOLS=$(tg-show-mcp-tools | grep "$SERVICE_NAME" | cut -d: -f1)

for tool in $MCP_TOOLS; do
    echo "Removing MCP tool for decommissioned service: $tool"
    tg-delete-mcp-tool --name "$tool"
done

Integration with Other Commands

With MCP Tool Management

List and delete MCP tools:

# List all MCP tools
tg-show-mcp-tools

# Delete specific MCP tool
tg-delete-mcp-tool --name unwanted-mcp

# Verify deletion
tg-show-mcp-tools | grep unwanted-mcp

With Configuration Management

Manage MCP tool configurations:

# View current configuration
tg-show-config

# Delete MCP tool
tg-delete-mcp-tool --name old-mcp

# View updated configuration
tg-show-config

With MCP Tool Invocation

Ensure MCP tools can't be invoked after deletion:

# Delete MCP tool
tg-delete-mcp-tool --name deprecated-mcp

# Verify tool is no longer available
tg-invoke-mcp-tool --name deprecated-mcp
# Should fail with tool not found error

Best Practices

  1. Verification: Always verify MCP tool exists before deletion
  2. Backup: Backup important MCP tool configurations before deletion
  3. Dependencies: Check for MCP tool dependencies before deletion
  4. Service Coordination: Coordinate with MCP service owners before deletion
  5. Testing: Test system functionality after MCP tool deletion
  6. Documentation: Document reasons for MCP tool deletion
  7. Gradual Removal: Remove MCP tools gradually in production environments
  8. Monitoring: Monitor for errors after MCP tool deletion

Troubleshooting

MCP Tool Not Found

If MCP tool deletion reports "not found":

  1. Verify the MCP tool name is correct
  2. Check MCP tool exists with tg-show-mcp-tools
  3. Ensure you're connected to the correct TrustGraph instance
  4. Check for case sensitivity in MCP tool name

Deletion Errors

If deletion fails:

  1. Check TrustGraph API connectivity
  2. Verify API permissions
  3. Check for configuration corruption
  4. Retry the deletion operation
  5. Check MCP service status

Permission Errors

If deletion fails due to permissions:

  1. Verify API access credentials
  2. Check TrustGraph API permissions
  3. Ensure proper authentication
  4. Contact system administrator if needed

Recovery

Restore Deleted MCP Tool

If an MCP tool was accidentally deleted:

  1. Use backup configuration if available
  2. Re-register the MCP tool with tg-set-mcp-tool
  3. Restore from version control if MCP tool definitions are tracked
  4. Contact system administrator for recovery options

Verify System State

After deletion, verify system state:

# Check MCP tool registry
tg-show-mcp-tools

# Verify no orphaned configurations
tg-show-config | grep "mcp\."

# Test MCP tool functionality
tg-invoke-mcp-tool --name remaining-tool

MCP Tool Lifecycle

Development to Production

Manage MCP tool lifecycle:

#!/bin/bash
# Promote MCP tool from dev to production

# Remove development version
tg-delete-mcp-tool --name dev-tool

# Add production version
tg-set-mcp-tool --name prod-tool --tool-url "http://prod.mcp.com/api"

Version Management

Manage MCP tool versions:

#!/bin/bash
# Update MCP tool to new version

# Remove old version
tg-delete-mcp-tool --name tool-v1

# Add new version
tg-set-mcp-tool --name tool-v2 --tool-url "http://new.mcp.com/api"

Security Considerations

When deleting MCP tools:

  1. Access Control: Ensure proper authorization for deletion
  2. Audit Trail: Log MCP tool deletions for security auditing
  3. Impact Assessment: Assess security impact of tool removal
  4. Credential Cleanup: Remove associated credentials if applicable
  5. Network Security: Update firewall rules if MCP endpoints are no longer needed

See Also

  • MCP Protocol Documentation
  • TrustGraph MCP Integration Guide
  • MCP Tool Management Manual