Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce mcp server cli adapter #166

Merged
merged 1 commit into from
Apr 5, 2025
Merged

Conversation

iocanel
Copy link
Contributor

@iocanel iocanel commented Mar 27, 2025

Resolves: #157

@iocanel iocanel requested a review from a team as a code owner March 27, 2025 20:40
@iocanel iocanel marked this pull request as draft March 27, 2025 20:40
@iocanel
Copy link
Contributor Author

iocanel commented Mar 27, 2025

I am currently working on the failing test.

@iocanel
Copy link
Contributor Author

iocanel commented Mar 31, 2025

@mkouba applied your feedback. I now have to fix the broken test. For some reason it's behaving pretty random (e.g. most of the time no response is received). Any insight?

@mkouba
Copy link
Contributor

mkouba commented Mar 31, 2025

@mkouba applied your feedback. I now have to fix the broken test. For some reason it's behaving pretty random (e.g. most of the time no response is received). Any insight?

I can try to take a look..

@iocanel iocanel force-pushed the mcp-cli-adapter branch 2 times, most recently from aa5cf2f to 673b071 Compare March 31, 2025 13:05
@mkouba
Copy link
Contributor

mkouba commented Mar 31, 2025

I think we should move the cli-adapter dir in the project root.

@iocanel
Copy link
Contributor Author

iocanel commented Apr 1, 2025

Added an abstract command that contains the --mcp flag and optionally starts the server or executes the actual command.

I tried to use byte code transformers to get the @TopCommand extend the forementioned abstract class but that does not work even though generated bytecode seems ok (after decompiling it). So, I guess its an order/visibility issue or something like it.

@iocanel iocanel force-pushed the mcp-cli-adapter branch 3 times, most recently from 5bcb33a to 9db5b6c Compare April 1, 2025 19:14
@iocanel iocanel marked this pull request as ready for review April 1, 2025 19:15
@iocanel
Copy link
Contributor Author

iocanel commented Apr 1, 2025

Currently, the user just needs to drop the dependency into a project that contains a @topcommand.
The extension will automagically add the --mcp option to the top command. When used it starts an mcp server with all the reachable subcommands added.

@iocanel iocanel requested a review from mkouba April 2, 2025 07:06
@geoand
Copy link
Contributor

geoand commented Apr 2, 2025

This is so cool!

Copy link
Contributor

@mkouba mkouba left a comment

Choose a reason for hiding this comment

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

It looks pretty cool. I've added a few minor comments.

@iocanel
Copy link
Contributor Author

iocanel commented Apr 3, 2025

@mkouba applied feedback

@iocanel iocanel requested a review from mkouba April 3, 2025 16:12
@melloware
Copy link

@iocanel i will definitely need this I have a CLI i want to test this with!

@mkouba mkouba merged commit 1d9cb2f into quarkiverse:main Apr 5, 2025
1 check passed
@melloware
Copy link

@iocanel i built this locally and trying it with my Picocli to get it running and I can't

My CLI: https://github.com/ksmpartners/domino-cli

When I added

        <dependency>
            <groupId>io.quarkiverse.mcp</groupId>
            <artifactId>quarkus-mcp-server-cli-adapter</artifactId>
            <version>999-SNAPSHOT</version>
        </dependency>

Then run mvn clean package

Then run java -jar domino-cli-6.0.1.2-SNAPSHOT.jar --mcp it ERRORS with...Unknown option: '--mcp'

@iocanel
Copy link
Contributor Author

iocanel commented Apr 7, 2025

Will have a look first thing in the morning

@mkouba
Copy link
Contributor

mkouba commented Apr 8, 2025

@iocanel i built this locally and trying it with my Picocli to get it running and I can't

My CLI: https://github.com/ksmpartners/domino-cli

When I added

        <dependency>
            <groupId>io.quarkiverse.mcp</groupId>
            <artifactId>quarkus-mcp-server-cli-adapter</artifactId>
            <version>999-SNAPSHOT</version>
        </dependency>

Then run mvn clean package

Then run java -jar domino-cli-6.0.1.2-SNAPSHOT.jar --mcp it ERRORS with...Unknown option: '--mcp'

Pls file a new issue.

@iocanel
Copy link
Contributor Author

iocanel commented Apr 8, 2025

@melloware: You should be using: java -jar target/quarkus-app/quarkus-run.jar --mcp instead, which from what I see is working fine.

@melloware
Copy link

@iocanel when I do that I get this error...

C:\dev\ksm\domino-cli>java -jar target/quarkus-app/quarkus-run.jar --mcp

Domino CLI
Usage: domino [-hV] [--mcp] [-k=<apiKey>] [-o=<outputFormat>]
              [-t=<timeoutSeconds>] [-u=<apiUrl>] [COMMAND]

Domino Data Lab Command Line Interface is a client to used provision and
control Domino.

  -h, --help           Show this help message and exit.
  -k, --key=<apiKey>   Domino API Key.
      --mcp            Start an MCP server for the current CLI.
  -o, --output=<outputFormat>
                       Output format TEXT, JSON, XML
  -t, --timeout=<timeoutSeconds>
                       Timeout in seconds waiting for Domino responses.
  -u, --url=<apiUrl>   Domino API URL.
  -V, --version        Print version information and exit.
Commands:
  collaborator
                Collaborator related functions
  dataset
                Dataset related functions
  datasource
                DataSource related functions
  goal
                Goal related functions
  job
                Job related functions
  user
                User related functions
  project
                Project related functions
  run
                Run related functions
  server
                Server related functions

Also it seems the uber-jar I build for JReleaser doesn't seem to contain this --mcp setting.

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.

Create an extension / integration for automatically exposing CLI commands as MCP tools.
4 participants