Skip to content

Instantly share code, notes, and snippets.

@up1
Last active July 24, 2026 09:28
Show Gist options
  • Select an option

  • Save up1/21c1e0d5d870918724c49b45e3308adb to your computer and use it in GitHub Desktop.

Select an option

Save up1/21c1e0d5d870918724c49b45e3308adb to your computer and use it in GitHub Desktop.
Install Quarkus Agent MCP
// 1. ติดตั้ง JBang
$curl -Ls https://sh.jbang.dev | bash -s - app setup
$bang --version
// 2. Start MCP Server
$jbang quarkus-agent-mcp@quarkusio --port 8080 --project-dir ./demo-app
// 3. ตัวอย่างการเพิ่ม MCP เข้าไปใน Claude Code
$claude mcp add quarkus-agent -- jbang quarkus-agent-mcp@quarkusio
// 1. Prompt การสร้าง REST API แบบง่าย ๆ
create a Quarkus REST API with PostgreSQL
GET /api/hi
return {"message": "Hello World"}, message from my_message table
// 2. การทำงานของ Claude Code จะทำการ load tools MCP ขึ้นมา และถามเพื่อ clarify requirement ต่าง ๆ
How should the app talk to PostgreSQL for reading the message from my_message?
❯ 1. Hibernate ORM with Panache
Entity-based repository pattern (Panache), the standard idiomatic Quarkus way. Extension: hibernate-orm-panache + jdbc-postgresql.
2. Plain JDBC / Agroal
Raw SQL via a DataSource, no ORM/entity mapping overhead. Extension: jdbc-postgresql + agroal.
3. Type something.
// 3. มี Rule ต่าง ๆ จาก Quarkus MCP ที่ได้เตรียมไว้
Tool use
quarkus-agent - quarkus_create(outputDir: "/demo-app", groupId: "com.example", artifactId: "demo-app", extensions: "rest-jackson,jdbc-postgresql,agroal", noCode: true, noWrapper: false) (MCP)
Create a new Quarkus application and auto-start it in dev mode.
RULES:
1) NEVER implement features manually when a Quarkus extension exists -- always search for and add the right extension first.
2) BEFORE creating the app or writing ANY code, use quarkus_searchTools query='extension' and quarkus_searchDocs to discover ALL extensions that can fulfill each requested capability. Present the full list of matching extensions to the user with a recommended default and WAIT for the user to choose. NEVER silently pick one.
3) Use quarkus_skills for each chosen extension BEFORE writing any code -- this is mandatory, not optional.
4) ALWAYS write tests for every feature if it makes sense and unless the user explicitly requested you not to.
5) Keep README.md updated with app description, features, endpoints, and Quarkus guide links after every change.
// 4. ยังไม่การอ่านข้อมูลพวก document ต่าง ๆ ผ่าน tools อีกด้วย
Used quarkus-agent: quarkus skills
Used quarkus-agent: quarkus searchDocs
Used quarkus-agent: quarkus searchDocs
Used quarkus-agent: quarkus searchDocs
Used quarkus-agent: quarkus searchDocs
Used quarkus-agent: quarkus searchDocs
Used quarkus-agent: quarkus searchDocs
Listed all project files
What was created (in my-quarkus-app, extensions: rest-jackson, agroal, jdbc-postgresql):
- HiResource.java — GET /api/hi, returns MessageResponse as JSON
- MessageRepository.java — plain JDBC query against my_message (SELECT message FROM my_message ORDER BY id LIMIT 1)
- MessageResponse.java — record {"message": ...}
- init-db.sql — creates my_message table and seeds it with ('Hello World'); auto-run against the Dev Services PostgreSQL container via quarkus.datasource.devservices.init-script-path
- HiResourceTest.java — @QuarkusTest + REST Assured, verifies the endpoint returns Hello World
- README updated with the endpoint, DB approach, and production datasource config notes
Verified: test suite passes (1/1), and curl http://localhost:8080/api/hi returns {"message":"Hello World"} live against the Dev Services Postgres instance.
Note: Dev Services requires Docker/Podman running locally — for production you'll need to set real %prod.quarkus.datasource.* connection properties (already sketched in the README) and ensure the my_message table exists there.
.
├── AGENTS.md
├── CLAUDE.md
├── README.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
│   ├── main
│   │   ├── docker
│   │   │   ├── Dockerfile.jvm
│   │   │   ├── Dockerfile.legacy-jar
│   │   │   ├── Dockerfile.native
│   │   │   └── Dockerfile.native-micro
│   │   ├── java
│   │   │   └── com
│   │   │   └── example
│   │   │   ├── HiResource.java
│   │   │   ├── MessageRepository.java
│   │   │   └── MessageResponse.java
│   │   └── resources
│   │   ├── application.properties
│   │   └── init-db.sql
│   └── test
│   ├── java
│   │   └── com
│   │   └── example
│   │   └── HiResourceTest.java
│   └── resources
// Resource file
@Path("/api/hi")
public class HiResource {
@Inject
MessageRepository messageRepository;
@GET
@Produces(MediaType.APPLICATION_JSON)
public MessageResponse hi() {
return new MessageResponse(messageRepository.findMessage());
}
}
// Repository with JDBC
@ApplicationScoped
public class MessageRepository {
@Inject
DataSource dataSource;
public String findMessage() {
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT message FROM my_message ORDER BY id LIMIT 1")) {
if (resultSet.next()) {
return resultSet.getString("message");
}
throw new IllegalStateException("No rows found in my_message table");
} catch (SQLException e) {
throw new RuntimeException("Failed to read message from my_message table", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment