Skip to main content
Glama

NestJS MCP Tool Demo

A minimal NestJS app that lets Claude use MCP-style tools backed by hardcoded JSON.


Setup

npm install

Create a .env file in the project root:

ANTHROPIC_API_KEY=sk-ant-...your key here...
ANTHROPIC_MODEL=claude-2  # optional override; set this to a model your Anthropic key supports

Start the server:

npx nest start --watch
# or: npm run start:dev

Server runs on http://localhost:3000


How to test in Postman

Endpoint

POST http://localhost:3000/ai/ask

Headers

Content-Type: application/json

Body (raw JSON)

{ "message": "What projects are currently active?" }

More example questions to try

{ "message": "Give me full details about the Alpha Launch project" }
{ "message": "Search for documents about authentication" }
{ "message": "Who owns the Gamma API project and what's the deadline?" }
{ "message": "List all projects and then show me the detail of the on-hold one" }

Example Postman response

{
  "answer": "There are two active projects:\n1. **Alpha Launch** (p1) — owned by Alice\n2. **Gamma API** (p3) — owned by Carol",
  "toolCallsUsed": ["get_project_list"],
  "timestamp": "2026-05-18T10:32:00.000Z"
}

The toolCallsUsed field shows exactly which MCP tools Claude chose to call. A log of every tool call is also written to tool-call-log.json in the project root.


Project structure

src/
  ai/
    tools.ts          ← JSON data + tool definitions + executor
    ai.service.ts     ← calls Claude API, runs the tool loop, writes logs
    ai.controller.ts  ← POST /ai/ask endpoint
    ai.module.ts
  app.module.ts
  main.ts

What happens inside (the tool loop)

  1. Postman sends { "message": "..." } to POST /ai/ask

  2. NestJS sends message + tool definitions to Claude API

  3. Claude replies with stop_reason: "tool_use" and picks a tool

  4. NestJS runs the tool against the hardcoded JSON → gets result

  5. NestJS writes the call to tool-call-log.json

  6. NestJS sends the result back to Claude

  7. Claude gives a final text answer (stop_reason: "end_turn")

  8. NestJS returns the answer + list of tools used to Postman

F
license - not found
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MagarongCandy/MCP_Tools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server