Skip to main content
Glama
jyeyeyej
by jyeyeyej

Mini Agent 03 · MCP

This is a small hands-on project that separates the travel Tool of mini_agent_03_tool into an MCP Server. The FastAPI Backend does not import Tool functions directly; instead, it discovers and calls Tools through the MCP Client.

Streamlit :8501
  → FastAPI Backend :8000
    → Travel MCP Server :8010/mcp (Streamable HTTP)
    → Policy MCP Server (stdio 자식 프로세스)
    → OpenAI Responses API가 한 번에 Tool 하나를 선택
      → Tool 결과를 돌려주고 필요한 만큼 반복

The Travel Server runs in a process and port independent from the Backend. The Policy Server is run by the Backend as a stdio child process. A single Agent uses both Transports together, learning Server prefixes, routing, and sequential Tool dependencies.

What changes from the stdio learning example

The Tool implementation and the meaning of MCP's tools/list and tools/call do not change. What changes is who runs the Server and the Transport that delivers messages.

Category

Policy MCP

Travel MCP

Transport

stdio

Streamable HTTP

Server execution

Backend automatically runs it as a child process

Runs independently in the first terminal

Address

Python file and run command

http://127.0.0.1:8010/mcp

Port

None

8010

Server lifetime

Terminates with the Client Session

Keeps running regardless of the Backend

Tools provided

Hotel policy lookup

Weather and hotel search

stdio
Backend → 자식 MCP Server

Streamable HTTP
Backend :8000 → 네트워크 → MCP Server :8010

The Frontend does not call the MCP Server directly. User requests always go through the Agent Backend, where GPT proposes Tools and the Backend handles permission checks, MCP calls, and result delivery. GPT does not execute MCP Tools directly.

Related MCP server: Trip Planner MCP Server

Features provided

  • GET /health: Backend status

  • GET /api/mcp/status: Connection status of the separate MCP Server

  • GET /api/mcp/tools: Discovers Tools exposed by the MCP Server

  • GET /api/mcp/resources: Discovers MCP Resources

  • POST /api/mcp/run: Question → Tool selection → MCP call → Answer trace

  • GET /api/mcp/baggage-policy: Reads an MCP Resource

Practice and execution order

Follow the execution order of the three processes. If you confirm that each preceding step is normal before moving to the next, you can easily tell which connection caused the problem.

0. 구조 확인
→ 1. 가상환경 준비
→ 2. OpenAI 환경변수 설정
→ 3. MCP Server 실행 (:8010)
→ 4. Backend 실행 (:8000)
→ 5. Backend에서 MCP 연결 확인
→ 6. GPT·Tool·Resource API 확인
→ 7. Frontend 실행 (:8501)
→ 8. 화면에서 전체 Trace 확인

Step 0 · Check the call structure

Before running the code, check the roles of the following four files.

File

Role

mcp_server/travel_server.py

HTTP Server exposing weather and hotel Tools and Resources

mcp_server/policy_stdio_server.py

stdio Server that looks up policies by hotel ID

backend/app/mcp_client.py

Client that creates and manages Sessions for both Transports

backend/app/agent.py

Manages Tool prefixes, routing, and the sequential Agent Loop

Step 1 · Prepare the virtual environment and packages

Run this only once.

cd C:\mini_agent_st\mini_agent_03_mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt

If you have already created .venv, just activate it from the next lesson onward.

cd C:\mini_agent_st\mini_agent_03_mcp
.\.venv\Scripts\Activate.ps1

Step 2 · Set the OpenAI environment variables

Copy .env.example to .env and enter the API Key you were issued.

Copy-Item .env.example .env
OPENAI_API_KEY=발급받은_API_KEY
OPENAI_MODEL=gpt-4.1-mini

Do not commit the API Key to Git or print it to the screen or logs.

Step 3 · Run the MCP Server

Open the first terminal and run it.

cd C:\mini_agent_st\mini_agent_03_mcp
.\.venv\Scripts\Activate.ps1
python .\mcp_server\travel_server.py

Do not close this terminal. The MCP endpoint is http://127.0.0.1:8010/mcp. When the console shows a message that the server is running on 127.0.0.1:8010, move on to the next step.

Step 4 · Run the FastAPI Backend

Open the second terminal and run it.

cd C:\mini_agent_st\mini_agent_03_mcp
.\.venv\Scripts\Activate.ps1
uvicorn backend.app.main:app --reload --port 8000

Check the Backend's own status.

Invoke-RestMethod http://127.0.0.1:8000/health

The key values in the expected result are as follows.

status      : ok
mcp_servers : travel=streamable-http, policy=stdio

Step 5 · Check the connection between the Backend and the MCP Server

Run this in a third PowerShell terminal.

Invoke-RestMethod http://127.0.0.1:8000/api/mcp/status

If it is working normally, status=connected and tool_count=3 are displayed. If you get a 503 here, check the MCP Server in the first terminal and TRAVEL_MCP_URL before running the Frontend.

Step 6 · Check the GPT, Tool, and Resource APIs

Check the Tools exposed by the MCP Server.

Invoke-RestMethod http://127.0.0.1:8000/api/mcp/tools |
    ConvertTo-Json -Depth 10

travel__get_current_weather, travel__search_hotels, policy__get_hotel_policy and each arguments Schema should be displayed.

Call the full Agent flow.

$body = @{
    question = "부산 날씨와 15만원 이하 호텔을 찾고 호텔 정책도 알려 주세요."
} | ConvertTo-Json
Invoke-RestMethod `
    -Uri http://127.0.0.1:8000/api/mcp/run `
    -Method Post `
    -ContentType "application/json" `
    -Body $body |
    ConvertTo-Json -Depth 10

Check the following order in the response.

available_tools
→ travel__get_current_weather
→ travel__search_hotels
→ 검색 결과에서 hotel_id 획득
→ policy__get_hotel_policy(hotel_id)
→ Function Call이 없는 응답에서 Loop 종료
→ 일반적으로 llm_calls = Tool 실행 수 + 1
→ answer

Also check the Resources.

Invoke-RestMethod http://127.0.0.1:8000/api/mcp/baggage-policy |
    ConvertTo-Json -Depth 10

Step 7 · Run the Streamlit Frontend

Open the fourth terminal and run it.

cd C:\mini_agent_st\mini_agent_03_mcp
.\.venv\Scripts\Activate.ps1
streamlit run frontend\app.py --server.port 8501

Open http://127.0.0.1:8501 in the browser. The FastAPI Swagger is at http://127.0.0.1:8000/docs.

Step 8 · Hands-on with the screen

Run the buttons in the following order.

  1. Check that the MCP connection status at the top is connected.

  2. Press MCP Tool 발견 to check the Tool names and Schemas.

  3. Run the MCP Agent with the default question.

  4. Check that only one Tool runs per Round.

  5. Check that the hotel_id from the hotel search results is passed to the Policy Tool arguments.

  6. Change the question to 서울에서 15만원 이하 호텔을 찾아 주세요. and compare Tool selection.

  7. Use 수하물 정책 읽기 to check a Resource lookup rather than a Tool.

Shutdown order

Press Ctrl+C in each running terminal.

Frontend 종료
→ Backend 종료
→ MCP Server 종료

If you shut down only the MCP Server first and then call /api/mcp/status again, you can also practice a connection failure where the Backend returns 503.

Comparison points

mini_agent_03_tool

mini_agent_03_mcp

Backend imports Tool functions directly

Backend uses only the MCP Client

Tool list is fixed in the Agent code

Discovered from the server via tools/list

Direct Python function calls

tools/call protocol calls

In-app Context

URI-based MCP Resource

Environment variables

BACKEND_API_URL=http://127.0.0.1:8000
TRAVEL_MCP_URL=http://127.0.0.1:8010/mcp
MCP_HOST=127.0.0.1
MCP_PORT=8010
OPENAI_API_KEY=발급받은_API_KEY
OPENAI_MODEL=gpt-4.1-mini

The Frontend only calls the Backend; the Backend manages the MCP Server URL and execution permissions.

The Backend prefixes the Tool Schemas discovered from the two MCP Servers with the Server prefix and passes them to the OpenAI Responses API. Because parallel_tool_calls=False, GPT proposes one Tool per Round. When the Backend returns the Tool result, GPT selects the next Tool, and the Agent Loop repeats until it answers without a Function Call.

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

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Hotel booking MCP server. Search, book, and manage reservations across 250K+ properties worldwide.

  • TravelMind: 8 MCP tools for travel (12306 trains, flights, hotels, geocode, planning, policy).

  • AI marketplace — flights, tours, activities, transport & more via MCP. No auth required.

View all MCP Connectors

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/jyeyeyej/mini_team_03_mcp'

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