Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rakdutta
Copy link
Collaborator

@rakdutta rakdutta commented Aug 19, 2025

Overview

This PR resolves issue #715 by implementing custom tool naming functionality and fixing field mapping inconsistencies in the tool edit screen. The changes improve the user experience by distinguishing between MCP and REST tool editing capabilities while maintaining backward compatibility.


Key Features

🔹 Custom Tool Naming

  • New custom_name field: Allows users to set display names independent of original MCP server tool names
  • Database migration: Safely transitions from original_name_slugcustom_name / custom_name_slug fields
  • Auto-population: Defaults custom_name to original_name if not explicitly provided
  • Slug generation: Automatically creates URL-safe custom_name_slug for internal routing

🔹 Enhanced Tool Edit Logic

MCP Tools (Read-only constraints):

  • URL field is read-only (cannot modify MCP server endpoints)
  • Headers, input schema, and auth fields are disabled
  • Integration type cannot be changed from MCP → REST
  • Prevents invalid configuration changes

REST Tools (Full editing):

  • All fields remain editable with validation
  • URLs, headers, schemas, and authentication are modifiable
  • Integration type can be changed between REST variants

🔹 UI/UX Improvements

  • Field validation for custom names using existing security patterns
  • Clear visual feedback for read-only vs editable fields
  • Alerts for invalid operations (e.g., REST → MCP conversion)
  • Hidden name field maintains API compatibility while displaying customName to users

Technical Details

Database Changes

ALTER TABLE tools DROP COLUMN original_name_slug;
ALTER TABLE tools ADD COLUMN custom_name VARCHAR;
ALTER TABLE tools ADD COLUMN custom_name_slug VARCHAR;

API Schema Updates

# ToolUpdate now supports custom naming
class ToolUpdate(BaseModel):
    name: Optional[str] = Field(None, description="Unique name for the tool")
    custom_name: Optional[str] = Field(None, description="Custom name for the tool")
    # ... other fields

# ToolRead includes both custom and computed names
class ToolRead(BaseModel):
    custom_name: str
    custom_name_slug: str
    # ... other fields

Frontend Logic

  • Tracks integration type changes to prevent invalid transitions
  • Dynamically enables/disables fields based on tool type
  • Provides immediate user feedback

Backward Compatibility

  • Migration strategy: Existing tools auto-populate custom_name_slug from original_name_slug
  • API compatibility: Extends functionality while keeping endpoints unchanged
  • Form handling: Hidden fields ensure submissions work with existing backend logic

Testing

Verified functionality through both the UI and API endpoints.

rakdutta1 and others added 30 commits August 14, 2025 18:03
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
* Add logging UI

Signed-off-by: Mihai Criveti <[email protected]>

* Add logging UI

Signed-off-by: Mihai Criveti <[email protected]>

* Add logging UI

Signed-off-by: Mihai Criveti <[email protected]>

* Add logging UI readme

Signed-off-by: Mihai Criveti <[email protected]>

* Update logging flake8

Signed-off-by: Mihai Criveti <[email protected]>

* Update logging flake8

Signed-off-by: Mihai Criveti <[email protected]>

* test coverage

Signed-off-by: Mihai Criveti <[email protected]>

* test coverage

Signed-off-by: Mihai Criveti <[email protected]>

* Fix download

Signed-off-by: Mihai Criveti <[email protected]>

* Fix test

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
* Fix download

Signed-off-by: Mihai Criveti <[email protected]>

* Reverse proxy

Signed-off-by: Mihai Criveti <[email protected]>

* Reverse proxy

Signed-off-by: Mihai Criveti <[email protected]>

* Reverse proxy

Signed-off-by: Mihai Criveti <[email protected]>

* doctest improvements

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
* Fix rpc endpoints
Signed-off-by: Madhav Kandukuri <[email protected]>

* Remove commented code
Signed-off-by: Madhav Kandukuri <[email protected]>

* remove duplicate code in session registry

Signed-off-by: Madhav Kandukuri <[email protected]>

* Linting fixes
Signed-off-by: Madhav Kandukuri <[email protected]>

* Fix tests
Signed-off-by: Madhav Kandukuri <[email protected]>

---------

Signed-off-by: Madhav Kandukuri <[email protected]>
* Fix tool invocation 'Invalid method' error with backward compatibility (IBM#753)

- Add backward compatibility for direct tool invocation (pre-PR IBM#746 format)
- Support both old format (method=tool_name) and new format (method=tools/call)
- Add comprehensive test coverage for RPC tool invocation scenarios
- Ensure graceful fallback to gateway forwarding when method is not a tool

The RPC endpoint now handles tool invocations in both formats:
1. New format: method='tools/call' with name and arguments in params
2. Old format: method='tool_name' with params as arguments (backward compat)

This maintains compatibility with existing clients while supporting the new
standardized RPC method structure introduced in PR IBM#746.

Signed-off-by: Mihai Criveti <[email protected]>

* Fix flake8 E722: Replace bare except with Exception

Signed-off-by: Mihai Criveti <[email protected]>

* lint

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
IBM#755)

- Added nosec B105 for ENV_TOKEN as it's an environment variable name, not a hardcoded secret
- Added nosec B110 for intentional exception swallowing in cleanup/error handling paths
- Both cases are legitimate uses where errors should be silently ignored to prevent cascading failures

Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Vinod Muthusamy <[email protected]>
Co-authored-by: Vinod Muthusamy <[email protected]>
* Implement comprehensive fuzz testing automation (IBM#256)

- Add property-based testing with Hypothesis for JSON-RPC, JSONPath, and schema validation
- Add coverage-guided fuzzing with Atheris for deep code path exploration
- Add API endpoint fuzzing with Schemathesis for contract validation
- Add security-focused testing for vulnerability discovery (SQL injection, XSS, etc.)
- Add complete Makefile automation with fuzz-all, fuzz-quick, fuzz-extended targets
- Add optional [fuzz] dependency group in pyproject.toml for clean installation
- Add comprehensive reporting with JSON/Markdown outputs and executive summaries
- Add complete developer documentation with examples and troubleshooting guides
- Exclude fuzz tests from main test suite to prevent auth failures
- Found multiple real bugs in JSON-RPC validation during development

Signed-off-by: Mihai Criveti <[email protected]>

* Update fuzz testing

Signed-off-by: Mihai Criveti <[email protected]>

* Update fuzz testing

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
* Update CORS

Signed-off-by: Mihai Criveti <[email protected]>

* Update CORS

Signed-off-by: Mihai Criveti <[email protected]>

* Update CORS ADRs

Signed-off-by: Mihai Criveti <[email protected]>

* Update CORS

Signed-off-by: Mihai Criveti <[email protected]>

* Update CORS

Signed-off-by: Mihai Criveti <[email protected]>

* Fix compose

Signed-off-by: Mihai Criveti <[email protected]>

* Update helm chart

Signed-off-by: Mihai Criveti <[email protected]>

* Update CORS docs

Signed-off-by: Mihai Criveti <[email protected]>

* Update test

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
* feat: Bulk Import Tools modal wiring and backend implementation

- Add modal UI in admin.html with bulk import button and dialog
- Implement modal open/close/ESC functionality in admin.js
- Add POST /admin/tools/import endpoint with rate limiting
- Support both JSON textarea and file upload inputs
- Validate JSON structure and enforce 200 tool limit
- Return detailed success/failure information per tool
- Include loading states and comprehensive error handling

Refs IBM#737

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Remove duplicate admin_import_tools function and fix HTML formatting

- Remove duplicate admin_import_tools function definition
- Fix HTML placeholder attribute to use double quotes
- Add missing closing div tag
- Fix flake8 blank line issues

Signed-off-by: Mihai Criveti <[email protected]>

* feat: Complete bulk import backend with file upload support and enhanced docs

- Add file upload support to admin_import_tools endpoint
- Fix response format to match frontend expectations
- Add UI usage documentation with modal instructions
- Update API docs to show all three input methods
- Enhance bulk import guide with UI and API examples

Backend improvements:
- Support tools_file form field for JSON file uploads
- Proper file content parsing with error handling
- Response includes imported/failed counts and details
- Frontend-compatible response format for UI display

Signed-off-by: Mihai Criveti <[email protected]>

* Bulk import

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Remove conflicting inline script and fix bulk import functionality

- Remove conflicting inline JavaScript that was preventing form submission
- Fix indentation in setupBulkImportModal function
- Ensure bulk import modal uses proper admin.js implementation
- Restore proper form submission handling for bulk import

This fixes the issue where bulk import appeared to do nothing.

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Integrate bulk import setup with main initialization

- Add setupBulkImportModal() to main initialization sequence
- Remove duplicate DOMContentLoaded listener
- Ensure bulk import doesn't interfere with other tab functionality

Signed-off-by: Mihai Criveti <[email protected]>

* fix: JavaScript formatting issues in bulk import modal

- Fix multiline querySelector formatting
- Fix multiline Error constructor formatting
- Ensure prettier compliance for web linting

Signed-off-by: Mihai Criveti <[email protected]>

* debug: Temporarily disable bulk import setup to test tabs

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Remove duplicate setupFormValidation call and delay bulk import setup

- Remove duplicate setupFormValidation() call that could cause conflicts
- Use setTimeout to delay bulk import modal setup after other initialization
- Add better null safety to form element queries
- This should fix tab switching issues

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Restore proper initialization sequence for tab functionality

- Remove setTimeout delay for bulk import setup
- Keep bulk import setup in main initialization but with error handling
- Ensure tab navigation isn't affected by bulk import modal setup

Signed-off-by: Mihai Criveti <[email protected]>

* fix: Correct HTML structure and restore tab navigation

- Move bulk import modal to correct location after tools panel
- Remove extra closing div that was breaking HTML structure
- Ensure proper page-level modal placement
- Restore tab navigation functionality for all tabs

This fixes the broken Global Resources, Prompts, Gateways, Roots, and Metrics tabs.

Signed-off-by: Mihai Criveti <[email protected]>

* feat: Add configurable bulk import settings

Configuration additions:
- MCPGATEWAY_BULK_IMPORT_MAX_TOOLS (default: 200)
- MCPGATEWAY_BULK_IMPORT_RATE_LIMIT (default: 10)

Implementation:
- config.py: Add new settings with defaults
- admin.py: Use configurable rate limit and batch size
- .env.example: Document all bulk import environment variables
- admin.html: Use dynamic max tools value in UI text
- CLAUDE.md: Document configuration options for developers
- docs: Update bulk import guide with configuration details

This makes bulk import fully configurable for different deployment scenarios.

Signed-off-by: Mihai Criveti <[email protected]>

* Update docs

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
Co-authored-by: Mihai Criveti <[email protected]>
* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export

Signed-off-by: Mihai Criveti <[email protected]>

* Import export testing

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
* Metadata / creation dates

Signed-off-by: Mihai Criveti <[email protected]>

* Metadata / creation dates

Signed-off-by: Mihai Criveti <[email protected]>

* Metadata / creation dates

Signed-off-by: Mihai Criveti <[email protected]>

* Security headers CSP

Signed-off-by: Mihai Criveti <[email protected]>

* Display metadata for resources
Signed-off-by: Madhav Kandukuri <[email protected]>

* eslint fix
Signed-off-by: Madhav Kandukuri <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
Co-authored-by: Madhav Kandukuri <[email protected]>
crivetimihai and others added 18 commits August 19, 2025 14:45
Signed-off-by: Mihai Criveti <[email protected]>
* Fix annotations edit

Signed-off-by: Mihai Criveti <[email protected]>

* Fix annotations edit

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
* feat: update context forge target in template's project dependencies

Signed-off-by: Frederico Araujo <[email protected]>

* fix: exclude jinja files from reformatting tabs

Signed-off-by: Frederico Araujo <[email protected]>

* fix: plugins cli defaults

Signed-off-by: Frederico Araujo <[email protected]>

* fix: revert formatted Makefile template

Signed-off-by: Frederico Araujo <[email protected]>

* feat: add optional packages

Signed-off-by: Frederico Araujo <[email protected]>

* docs: update plugin template docs

Signed-off-by: Frederico Araujo <[email protected]>

* docs: update template readme

Signed-off-by: Frederico Araujo <[email protected]>

---------

Signed-off-by: Frederico Araujo <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
@rakdutta rakdutta changed the title Fix Tool Edit Screen: Field Mapping Consistency and implement edit logic for MCP tools Fix Tool Edit Screen: Field Mapping Consistency and Custom Tool Naming Implementation Aug 20, 2025
Signed-off-by: RAKHI DUTTA <[email protected]>
@rakdutta rakdutta marked this pull request as ready for review August 20, 2025 06:36
Copy link
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected.

  1. Added tools with MCP server
  2. Updated tool name from edit tool box
  3. Tool shows with updated name in gateway and other clients like MCP Inspector and tool works.

GOOD TO MERGE.

@rakdutta Do we need to allow editing name in update_tool function in tool_service?

Copy link
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and tested

@crivetimihai crivetimihai merged commit df217a1 into IBM:main Aug 20, 2025
36 checks passed
@rakdutta
Copy link
Collaborator Author

@madhav165
Raised PR #805
to remove name update logic from tool_service.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]:Tool Edit Screen Issues – Field Mismatch & MCP Tool Validation Error