|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: 'Introducing Model Context Protocol servers project' |
| 4 | +date: 2025-01-28 |
| 5 | +tags: ai |
| 6 | +synopsis: Introducing the Model Context Protocol servers project which provides a set of MCP servers implemented using Quarkus and Java. Starting with JDBC, filesystem and JavaFX. |
| 7 | +author: maxandersen |
| 8 | +--- |
| 9 | +:imagesdir: /assets/images/posts/mcpservers |
| 10 | +ifdef::env-github,env-browser,env-vscode[:imagesdir: ../assets/images/posts/mcpservers] |
| 11 | + |
| 12 | +Today, I'm excited to introduce the Model Context Protocol (MCP) servers project. |
| 13 | + |
| 14 | +Model Context Protocol is the recent approach to enable AI models to interact with your applications and services in a nice decoupled way. |
| 15 | + |
| 16 | +The https://github.com/quarkiverse/quarkus-mcp-servers[mcp-servers] project is as far as I know the first one to provide a set of MCP servers implemented using Java and at least uniquely Quarkus. |
| 17 | + |
| 18 | +Intended to show-case the capabilities of the Model Context Protocol, and inspiration for what you can do with it - especially in Java. |
| 19 | + |
| 20 | +== The Servers |
| 21 | + |
| 22 | +At time of writing there are three servers implemented: |
| 23 | + |
| 24 | +JDBC:: Let your AI app introspect and interact to any JDBC-compatible database, let it be PostgreSQL, MySQL, MariaDB, SQLite, Oracle, etc. |
| 25 | + |
| 26 | +Filesystem:: Access the file system of your machine, let it be your home directory, your code directory, your project directory, etc. |
| 27 | + |
| 28 | +JavaFX:: Draw on a JavaFX canvas, get your AI to draw some art for you! |
| 29 | + |
| 30 | +Each server is implemented using Quarkus and Java, and each server is available to easily run using JBang. |
| 31 | + |
| 32 | +== How to use the servers |
| 33 | + |
| 34 | +The general setup is to install JBang (no need for Java, Quarkus or any other Java tool installed). |
| 35 | + |
| 36 | +Then in your MCP client configure it with: |
| 37 | + |
| 38 | +`jbang [server-name]@quarkiverse/quarkus-mcp-servers [arguments]` |
| 39 | + |
| 40 | +Thus for example to run the JDBC server to connect to a MariaDB database you would do: |
| 41 | + |
| 42 | +`jbang mcp-jdbc-server@quarkiverse/quarkus-mcp-servers jdbc:mariadb://localhost:3306/test --user root --password mysecretpassword` |
| 43 | + |
| 44 | +or use a downlodable SQLite database of Netflix movies: |
| 45 | + |
| 46 | +`jbang mcp-jdbc-server@quarkiverse/quarkus-mcp-servers jdbc:sqlite:%{https://github.com/lerocha/netflixdb/releases/download/v1.0.0/netflixdb.sqlite}` |
| 47 | + |
| 48 | +TIP: Tthe `%{}` syntax is a JBang feature to download a file from a URL in the command line and use it as a local file. |
| 49 | + |
| 50 | +== Tested MCP Clients |
| 51 | + |
| 52 | +During development we tested the servers with the following clients: |
| 53 | + |
| 54 | +* Claude Desktop |
| 55 | +* mcp-cli |
| 56 | +* Goose |
| 57 | + |
| 58 | +There are more MCP clients out there, and we're sure that the servers will work with many more. |
| 59 | + |
| 60 | +Goose is noteworthy given it is opensource and available both as a desktop app (on MacOS) and as a cli tool. It was https://block.github.io/goose/docs/quickstart/[recently announced] with full support for the Model Context Protocol. |
| 61 | + |
| 62 | +Here I configured Goose to use the SQLLite database from the Northwind sample database with this setup stored in `~/.config/goose/config.yaml`: |
| 63 | + |
| 64 | +```yaml |
| 65 | +extensions: |
| 66 | + netflixdb: |
| 67 | + args: |
| 68 | + - jdbc@quarkiverse/quarkus-mcp-servers |
| 69 | + - jdbc:sqlite:%{https://github.com/lerocha/netflixdb/releases/download/v1.0.0/netflixdb.sqlite} |
| 70 | + cmd: jbang |
| 71 | + enabled: true |
| 72 | + envs: {} |
| 73 | + name: netflixdb |
| 74 | + type: stdio |
| 75 | +``` |
| 76 | + |
| 77 | +Note: we do recommend to use `goose config` to generate/edit the config file. |
| 78 | + |
| 79 | +With the above config Goose will be able to use the JDBC server to connect to the SQLLite database: |
| 80 | + |
| 81 | +image::mcp-jdbc-goose.png[Goose using the JDBC server to connect to the SQLLite database] |
| 82 | + |
| 83 | +== Unique features for Quarkus MCP Servers |
| 84 | + |
| 85 | +All that is great, but why use Quarkus for implementing the MCP servers? |
| 86 | + |
| 87 | +First is that the programming model provided by Quarkus is very powerful, allowing you to easily focus on the business logic of your application. See https://quarkus.io/blog/mcp-server/[previous blog] for details on how to implement a server or look at the https://github.com/quarkiverse/quarkus-mcp-servers/blob/main/jdbc/src/main/java/io/quarkus/mcp/servers/jdbc/MCPServerJDBC.java[code of the JDBC servers]. Notice how compact it is! |
| 88 | + |
| 89 | +Second, is the wast Java ecosystem provides things like JDBC drivers which enables us to make a single server that works with any JDBC-compatible database. We use `jbang` to dynamically download https://github.com/quarkiverse/quarkus-mcp-servers/blob/main/jdbc/.scripts/mcpjdbc.java[the right JDBC driver] and then launch the quarkus mcp server. Similar is done for `jfx` to https://github.com/quarkiverse/quarkus-mcp-servers/blob/main/jbang-catalog.json#L34[fetch] the right OS specific JavaFX dependencies. |
| 90 | + |
| 91 | +Thirdly, ability to run the servers as a native executable. In the MCP servers project the `filesystem` server is https://github.com/quarkiverse/quarkus-mcp-servers/releases[published as a native executable] you can download and gain a much faster startup time. |
| 92 | + |
| 93 | +== Sky is the limit! |
| 94 | + |
| 95 | +The Model Context Protocol opens up exciting possibilities for building intelligent applications using your application data with your favourte programming language and framework. With Quarkus MCP Servers, you have a powerful foundation to create your own Java based servers that can bridge AI with any data source or system you can imagine. |
| 96 | + |
| 97 | +Whether you want to connect to your favorite database, integrate with your company's internal systems, or build something completely new - the sky truly is the limit! The simplicity of implementing MCP servers with Quarkus means you can focus on the creative aspects rather than the plumbing. |
| 98 | + |
| 99 | +We'd love to see what you build! Leave a comment or consider contributing your MCP servers back to the community through the https://github.com/quarkiverse/quarkus-mcp-servers[Quarkiverse MCP Servers project]. Your implementation could help others solve similar problems or inspire them to create something even more amazing. |
| 100 | + |
| 101 | +So what are you waiting for? Grab the code, fire up your IDE, and start building your own MCP server today. The future of AI-powered applications is here, and you can be part of shaping it! |
| 102 | + |
| 103 | +Have Fun! |
| 104 | + |
| 105 | + |
0 commit comments