Skip to content

fix(resources/prompts): list correctly; add resource read, prompt get, and Type column#244

Open
dariushoule wants to merge 3 commits into
IBM:mainfrom
dariushoule:fix/list-resources-prompts-async-typed
Open

fix(resources/prompts): list correctly; add resource read, prompt get, and Type column#244
dariushoule wants to merge 3 commits into
IBM:mainfrom
dariushoule:fix/list-resources-prompts-async-typed

Conversation

@dariushoule

@dariushoule dariushoule commented Jun 8, 2026

Copy link
Copy Markdown

Summary

mcp-cli resources and mcp-cli prompts always print "No resources available." /
"No prompts available." even when the server exposes them; there is no way to read
a resource or fetch a prompt; and the resources table's Type column always shows
unknown. This PR fixes all of it.

1. Listing always empty (root cause)

ToolManager.list_resources / list_prompts were synchronous stubs that returned the
un-awaited coroutine from the (async) StreamManager and never converted the result, so
the commands (which await them and access resource.id / prompt.name) always saw
nothing — and would AttributeError on a dict once data was available. Contrast
get_all_tools, which already awaits and converts to ToolInfo.

Fix: make both async, await the StreamManager, and convert each raw dict to a typed
object — ResourceInfo.from_raw (existed) / a new PromptInfo model.

2. Read a resource / fetch a prompt

ToolManager.read_resource existed but had no CLI/chat surface, and there was no
get_prompt path at all.

Fix:

  • mcp-cli resources --read <uri> — print a resource's contents.
  • mcp-cli prompts --get <name> — fetch and render a prompt's messages (adds
    ToolManager.get_prompt; the prompts command already declared a get parameter that was
    never implemented).

(Both also work as the read / get parameters in chat and interactive modes.)

3. Type column always "unknown"

The command read resource.type or resource.extra.get("mime_type"), but MCP resources use
mimeType (and are identified by uri).

Fix: ResourceInfo.from_raw normalizes uriid and mimeTypetype (originals
preserved in extra), so the Type column is populated.

Tests

  • ToolManager.list_resources/list_prompts/get_prompt rewritten/added to the async + typed
    contract (the previous list tests asserted the buggy synchronous passthrough).
  • ResourceInfo.from_raw normalization cases + new PromptInfo unit tests.
  • resources --read and prompts --get command tests (success + not-found).
  • Existing command tests already mocked list_resources/list_prompts as async returning
    ResourceInfo objects — this aligns the implementation with that contract — and still pass.
  • Affected suites (tests/tools + tests/commands/definitions) all green. (Unrelated
    pre-existing Windows-console charmap failures in chat-banner tests are untouched.)

Companion fix

End-to-end output depends on chuk-tool-processor returning the data: its stdio/HTTP
transports discard the pydantic *Result models, and StreamManager lacked get_prompt.
Both are fixed in IBM/chuk-tool-processor#45. With that plus this PR, mcp-cli resources
and prompts list, read/get, and show types correctly.

dariushoule and others added 3 commits June 8, 2026 09:43
…turn typed objects

ToolManager.list_resources and list_prompts were synchronous stubs that
returned the un-awaited coroutine from the (async) StreamManager and never
converted the result. The resources/prompts commands await these methods
and access attributes (resource.id, prompt.name, ...), so listing always
ended in "No resources available." / "No prompts available." — and would raise
AttributeError on a dict once data was actually available.

- Make both methods async, await the StreamManager, and convert each raw
  dict via ResourceInfo.from_raw (already existed) / PromptInfo.from_raw.
- Add a PromptInfo model mirroring ResourceInfo.
- Update the ToolManager unit tests to the async + typed-object contract; they
  previously asserted the buggy synchronous passthrough.

The existing command tests already mock these methods as async returning
ResourceInfo objects, i.e. this aligns the manager with the contract the rest
of the codebase already assumes.

Signed-off-by: Darius Houle <darius@x64.ooo>
- Add `mcp-cli resources --read <uri>` (and a `read` parameter for chat /
  interactive modes) to print a resource's contents, wiring up the existing
  ToolManager.read_resource which previously had no CLI/chat surface.
- ResourceInfo.from_raw now normalizes MCP's `uri` -> id and `mimeType` -> type
  so the resources table's Type column is populated instead of always "unknown";
  the original keys are preserved in `extra`.
- Tests: ResourceInfo.from_raw normalization cases, PromptInfo unit tests, and
  `resources --read` command tests (success + not-found).

Signed-off-by: Darius Houle <darius@x64.ooo>
Wire ToolManager.get_prompt (delegating to StreamManager.get_prompt) and implement
the prompts command's existing `get` parameter plus the `mcp-cli prompts --get` CLI
option, rendering the returned messages. Symmetric to `resources --read`.

Tests: ToolManager.get_prompt (no-manager / success / error); prompts `--get`
command tests (renders messages; missing prompt -> failure).

Signed-off-by: Darius Houle <darius@x64.ooo>
@dariushoule dariushoule changed the title fix(resources): make resources/prompts listing work, add resource read + Type column fix(resources/prompts): list correctly; add resource read, prompt get, and Type column Jun 8, 2026
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.

1 participant