Skip to content

Sample on how you can consume any REST API from an OpenAPI file and save data to MongoDB and generate Java code for this too, using Claude Cod,e without knowing the API structure or writing any code

License

Notifications You must be signed in to change notification settings

xoriors/claude-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

claude-agent

Docker Hub

Sample on how you can consume any REST API from an OpenAPI file, save data to MongoDB and generate Java code for this too, using Claude Code, without knowing the API structure or writing any code.

Warning

This is just experimental at this point; it is still under development. Please do not use it with sensitive data for now; please wait for a stable release.
It's mostly ideal for experimental and learning projects.**

What you can do

  • Add MCP server for any REST API with OpenAPI specs
  • We have already configured MCP servers for petstore and weather API
  • Discover what we can do with the API
  • Simple flow on how to consume the API without knowing the structure
  • Saving the data in mongodb
  • A more complex example with a flow that requires several API calls
  • Generate code for the above flows

Use docker compose

Get docker-compose.yml and save it in a folder where you'll run the next commands.

Start the container (only one time)

docker compose up -d

Connect to existing container (next times)

docker compose attach claude-agent

Execute commands in container

See more

Play with it

claude

Handle login.

Select the model you want

/model

Discover what we can do with the API

short summary of what weather tools offer

Simple query

get top 3 active weather alerts for today in US Florida, show them and also save them using mongodb tools in db named weather and collection named alerts

Check if data was inserted in mongodb

mongosh --quiet --eval "use('weather'); db.alerts.find().pretty()"

More complex query, notice how it calls several endpoints to get all that's needed

discover what tools to call from weather tools to get temperature, cloud cover and wind speed for last 3 days, all measurements per day, in palo alto, show them as table and have them in mongodb tools in db weather collections historical

Check if data was inserted in mongodb

mongosh --quiet --eval "use('weather'); db.historical.find().pretty()"

View tools

/mpc

Now generate code

generate a new project in weather-api-client folder for the 2 flows from above, alerts and historic data
first generate detailed asciiart diagrams for all the implementation (add this to README.md) and then the actual code
respsect these:
- git initiated
- springboot
- java21
- okhttp code for RST API calls to weather tools
- jackson json
- clean code, KISS and SOLID
- persistence layer on mongodb
- generate extensive unit and integration tests for all flows
- test and run and the app
then commit tme with relevant commit message

View diagrams while generating the code. You could first review and change the diagrams as needed, and then generate the code based on those

Check the code and run some tests

give me curl samples how to test it and does it really save the data in mongodb

Cleanup

mongosh weather --eval "db.dropDatabase()" --quiet
rm -rf weather-api-client

Stop the container

docker compose down

Remove the container (WARN: DATA WILL BE LOST)

docker compose down

Build Docker

The Dockerfile is based on claude-code/.devcontainer

cd docker
docker buildx build --sbom=true --provenance=true -t xorio42/claude-agent .

Sample

WhatsApp Image 2025-09-21 at 20 06 31 WhatsApp Image 2025-09-21 at 20 06 31 WhatsApp Image 2025-09-21 at 20 06 31 (1) WhatsApp Image 2025-09-21 at 20 06 31 (2) WhatsApp Image 2025-09-21 at 20 06 31 (3) WhatsApp Image 2025-09-21 at 20 06 31 (4) WhatsApp Image 2025-09-21 at 20 10 50 WhatsApp Image 2025-09-21 at 20 15 24 WhatsApp Image 2025-09-21 at 20 15 25 WhatsApp Image 2025-09-21 at 20 16 39 WhatsApp Image 2025-09-21 at 20 18 05

About

Sample on how you can consume any REST API from an OpenAPI file and save data to MongoDB and generate Java code for this too, using Claude Cod,e without knowing the API structure or writing any code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published