Skip to content

fix(ui): show federated prompt arguments in Admin UI instead of empty list#3602

Merged
crivetimihai merged 2 commits intomainfrom
fix/3447-prompt-arguments-empty-ui
Mar 12, 2026
Merged

fix(ui): show federated prompt arguments in Admin UI instead of empty list#3602
crivetimihai merged 2 commits intomainfrom
fix/3447-prompt-arguments-empty-ui

Conversation

@shoummu1
Copy link
Copy Markdown
Collaborator

📌 Summary

Prompts registered via federated MCP servers always showed an empty argument list in the Admin UI. The arguments panel displayed {} instead of the actual argument names, descriptions, and required flags defined in the upstream MCP server.

🔗 Related Issue

Closes: #3447

🔁 Reproduction Steps

See #3447. Briefly:

  1. Register an MCP server that exposes a prompt with arguments (e.g. greet_user(name, style)).
  2. Open the Admin UI → Prompts → click the registered prompt.
  3. The Arguments panel shows {} and the Test Prompt form shows no input fields.

🐞 Root Cause

In gateway_service.py, every code path that creates or updates a federated DbPrompt hardcoded argument_schema={}, discarding the argument metadata returned by the upstream server in the prompts/list MCP response.

As a result, convert_prompt_to_read() in prompt_service.py (which reconstructs the arguments list by iterating over argument_schema["properties"]) always returned an empty list, so the UI had nothing to render.

Additionally, in admin.js the fallback for missing arguments used || {} (an object) instead of || [] (an array), and there was no human-readable "No arguments" message for prompts that genuinely have none.

💡 Fix Description

Backend (gateway_service.py):

  • Added static helper _build_prompt_argument_schema(prompt) that converts the MCP arguments list (items with name, description, required) into the internal {"type": "object", "properties": {...}, "required": [...]} JSON schema — consistent with what prompt_service.py already does for user-created prompts.
  • Applied this helper in all 4 locations where argument_schema={} was hardcoded: federation create, federation orphan-reassign, _update_or_create_prompts create branch, and _update_or_create_prompts update branch.
  • Added argument_schema to the change-detection condition so that an upstream argument change triggers a DB update.

Frontend (admin.js):

  • Fixed || {}|| [] fallback in the edit modal (correct type for validateJson).
  • Replaced the raw JSON.stringify(prompt.arguments || {}) in the view details panel with a conditional that renders "No arguments" when the list is empty and a formatted JSON array otherwise.

🧪 Verification

Check Command Status
Lint suite make lint Passed
Unit tests make test Passed
Coverage ≥ 90 % make coverage Passed
Manual regression no longer fails Register MCP server with prompt arguments → Admin UI now shows argument list and test form fields Passed

📐 MCP Compliance (if relevant)

  • Matches current MCP spec (prompts/list argument metadata: name, description, required)
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

@marekdano
Copy link
Copy Markdown
Collaborator

@shoummu1 - can you please resolve conflicts?

@shoummu1 shoummu1 force-pushed the fix/3447-prompt-arguments-empty-ui branch from 92e2aea to 3393c27 Compare March 11, 2026 09:24
@shoummu1
Copy link
Copy Markdown
Collaborator Author

@marekdano Thanks! I've rebased and resolved the conflicts in this PR.

marekdano
marekdano previously approved these changes Mar 11, 2026
Copy link
Copy Markdown
Collaborator

@marekdano marekdano left a comment

Choose a reason for hiding this comment

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

Summary
This PR addresses prompt argument display issues in the Admin UI and reverts a previous database schema change for A2A agents.

✅ Positive Changes

1. Prompt Argument Schema Population (gateway_service.py)
   - Added _build_prompt_argument_schema() static method to properly convert MCP prompt arguments into JSON schema format
   - Method correctly handles: empty arguments, missing attributes, descriptions, and required fields
   - Integrated into both _sync_gateway_metadata() and _update_or_create_prompts()
   - Excellent test coverage with 3 comprehensive unit tests

2. UI Fix (admin.js)
   - Fixed empty arguments display to show "No arguments" instead of empty JSON object
   - Improved user experience when viewing prompts without arguments

3. Test Quality
   - Well-structured tests for _build_prompt_argument_schema()
   - Tests cover edge cases (empty, missing attributes, None descriptions)
   - Updated existing tests to expect proper schema structure

Code Quality:
- ✅ Follows coding standards (type hints, docstrings)
- ✅ Good test coverage for new functionality
- ✅ Proper error handling in _build_prompt_argument_schema()

It was also manually tested, and I can confirm that arguments in prompts display as expected.

LGTM

@marekdano marekdano added ui User Interface release-fix Critical bugfix required for the release labels Mar 11, 2026
@shoummu1 shoummu1 force-pushed the fix/3447-prompt-arguments-empty-ui branch from 3393c27 to 2e9c062 Compare March 12, 2026 05:57
shoummu1 and others added 2 commits March 12, 2026 12:42
…ents display in Admin UI

Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
…and real arguments

Cover the new argument_schema integration in _update_or_create_prompts:
- arguments=None handling in _build_prompt_argument_schema
- new prompts with real arguments populate argument_schema correctly
- argument_schema change alone triggers prompt update
- no update when argument_schema is unchanged

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Copy link
Copy Markdown
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 onto main (clean, no conflicts) and added 4 tests for full differential coverage of the new code paths.

Backend review — All 4 locations where argument_schema={} was hardcoded are now correctly using _build_prompt_argument_schema(). The helper is consistent with the existing inline pattern in prompt_service.py, with the intentional difference that required is derived from MCP metadata rather than template placeholders — correct for federated prompts. Change detection at line 4322 properly handles None from old DB rows via or {}.

Frontend review — The || {}|| [] fix is correct (prompt.arguments is an array). The "No arguments" fallback is a good UX improvement. Compatible with buildPromptTestForm() which already expects array items with name/description/required.

Security — No new endpoints, no auth changes, no unsanitized user input. No issues.

Tests added (commit 729d68c):

  • test_build_prompt_argument_schema_arguments_none — handles arguments=None
  • test_update_or_create_prompts_new_prompt_with_arguments — real arguments flow through to argument_schema
  • test_update_or_create_prompts_argument_schema_change_triggers_update — schema-only change triggers update
  • test_update_or_create_prompts_no_update_when_schema_unchanged — no spurious update when schema is identical

All 49 tests pass.

@crivetimihai crivetimihai self-assigned this Mar 12, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0 milestone Mar 12, 2026
@crivetimihai crivetimihai merged commit 1152eb0 into main Mar 12, 2026
47 checks passed
@crivetimihai crivetimihai deleted the fix/3447-prompt-arguments-empty-ui branch March 12, 2026 13:22
Yosiefeyob pushed a commit that referenced this pull request Mar 13, 2026
… list (#3602)

* populate prompt argument_schema from MCP metadata and fix empty arguments display in Admin UI

Signed-off-by: Shoumi <shoumimukherjee@gmail.com>

* test: add differential coverage for argument_schema change detection and real arguments

Cover the new argument_schema integration in _update_or_create_prompts:
- arguments=None handling in _build_prompt_argument_schema
- new prompts with real arguments populate argument_schema correctly
- argument_schema change alone triggers prompt update
- no update when argument_schema is unchanged

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
calculus-ask pushed a commit to calculus-ask/mcp-context-forge that referenced this pull request Mar 18, 2026
… list (IBM#3602)

* populate prompt argument_schema from MCP metadata and fix empty arguments display in Admin UI

Signed-off-by: Shoumi <shoumimukherjee@gmail.com>

* test: add differential coverage for argument_schema change detection and real arguments

Cover the new argument_schema integration in _update_or_create_prompts:
- arguments=None handling in _build_prompt_argument_schema
- new prompts with real arguments populate argument_schema correctly
- argument_schema change alone triggers prompt update
- no update when argument_schema is unchanged

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: KRISHNAN, SANTHANA <sk8069@exo.att.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-fix Critical bugfix required for the release ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][UI]: Prompts show empty argument list in Admin UI

3 participants