Skip to content

Conversation

@johnstcn
Copy link
Contributor

@johnstcn johnstcn commented Apr 6, 2025

While investigating a separate issue (PR incoming), I noticed that the TestResourcesCmdRun_Success had been recently skipped. This led me down a small rabbit hole of fixing up the output of that command.

Here's what I changed:

  • pkg/jsonutils:
    • Adds description field to the output of the resources command, which was the original reason for the test being skipped.
    • Modifies formatResourcesList to correctly align with and without coloured output (pet peeve). The main thing to note here is that text/tabwriter's elastic tabstop algorithm still considers colour escape sequences as part of the 'cells', so it's important to take the length of those sequences into account. I ended up also colouring the second line of the output, but can keep it uncoloured if you prefer (EDIT: this might not be as straightforward as I originally thought).
    • Renames the type field of the resources command to the correct mimeType.
  • cmd/mcptools/commands:
    • Updates and un-skips the test TestResourcesCmdRun_Success.

The below sample output is from an MCP server I am currently working on.

Before:

NAME               TYPE  URI
----                            ----           ---
Coder User By ID                  coder://user/{id}
Coder Templates                   coder://templates
Coder Workspaces                  coder://workspaces{?limit,offset,owner}
Coder Workspace by ID             coder://workspace/{id}

After:

NAME                   MIMETYPE          URI                                      DESCRIPTION
----                   --------          ---                                      ----------
Coder User By ID       application/json  coder://user/{id}                        Information about a given Coder user. The strin...
Coder Templates        application/json  coder://templates                        List of all Coder templates available to the cu...
Coder Workspaces       application/json  coder://workspaces{?limit,offset,owner}  List of Coder workspaces with optional filterin...
Coder Workspace by ID  application/json  coder://workspace/{id}                   Detailed information about a specific Coder wor..

@f f merged commit 9846b73 into f:master Apr 6, 2025
2 checks passed
@johnstcn johnstcn deleted the cj/unskip/TestResources branch April 6, 2025 17:02
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.

2 participants