mcp-openapi-demo
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-openapi-demoShow me all available pets"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-openapi-demo
Model Context Protocol
“LLM function calling” mekanizması ile MCP’yi otomatik tetikleyen küçük bir demo.
📂 Proje Dizini
mcp-openapi-demo/
│
├── server.js # Node.js tarafı → MCP Server (Petstore API)
├── package.json # Node bağımlılıkları
├── .env # Ortam değişkenleri (API anahtarı vs.)
└── python-client/
├── client.py # Python tarafı → MCP Client (OpenAI entegrasyonu ile)Related MCP server: mcp_sdk_petstore_api
Proje Nasıl Çalışır
👉 Modele sadece “Find available pets” denir. 👉 Model, kendi isteğiyle function call yapacak. 👉 Python kodu, bu function call’u yakalayacak, MCP server’a yönlendirecek, cevabı alacak. 👉 Sonucu tekrar modele verip son yanıtı yazdıracak.
🚀 Adım 1: MCP Server’ı Çalıştır
Önce Node.js tarafını aç ve terminalde:
cd mcp-openapi-demo
node server.jsEğer doğruysa:
🚀 MCP Server running on http://localhost:4000mesajını görmen lazım ✅
🚀 Adım 2: Python Ortamını Kur
Python client klasörüne geç:
cd python-client
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install requests openai🚀 Adım 3: OpenAI API Key Ayarla
API anahtarını .env dosyasına yazabilirsin:
OPENAI_API_KEY=senin_api_keyPython kodunda anahtarı almak için python-dotenv paketini kur:
pip install python-dotenvVe client.py içinde şöyle ekle:
from dotenv import load_dotenv
load_dotenv()Artık anahtar otomatik olarak .env dosyasından alınacak.
🚀 Adım 4: Python Client Çalıştır
python client.pyBeklenen çıktı:
Önce Petstore API’den gelen JSON → yani “available pets” listesi.
Ardından OpenAI modelinin doğal dilde özeti → mesela “There are 20 available pets, most are dogs and cats...” gibi.
📌 Özetle:
Node.js tarafı → Petstore MCP Server
Python tarafı → Hem MCP’den veri çekiyor hem de OpenAI modeline verip yorum alıyor
LLM Function Calling Mekanizması Nasıl Çalışır?
👉 Modelin "find_available_pets" fonksiyonunu çağırması senin yazdığın prompt + ona verdiğin tools tanımı sayesinde oluyor. Yani bu çağrı senin API çağrının bir yanıtı olarak, modelin output’unda gerçekleşiyor.
📍 Nerede olur?
OpenAI’nin chat.completions.create cevabında olur.
Örneğin Python’da:
from openai import OpenAI
client = OpenAI()
tools = [
{
"type": "function",
"function": {
"name": "find_available_pets",
"description": "Find pets in the Petstore API by status",
"parameters": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["available", "pending", "sold"]
}
},
"required": ["status"],
},
}
}
]
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "Can you show me all available pets?"}
],
tools=tools
)
print(response.choices[0].message)📍 Modelin cevabı nasıl olur?
Model sana düz metin dönmez, function call döner:
{
"role": "assistant",
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {
"name": "find_available_pets",
"arguments": "{ \"status\": \"available\" }"
}
}
]
}📍 Sen ne yaparsın?
Buradaki
function.nameveargumentsdeğerini alırsın.Bu bilgiyi MCP server’a JSON-RPC request olarak gönderirsin (
pet/findByStatus).Dönen cevabı tekrar modele verirsin →
client.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "user", "content": "Can you show me all available pets?"}, response.choices[0].message, # function call çıktısı { "role": "tool", "tool_call_id": response.choices[0].message.tool_calls[0].id, "content": json.dumps(mcp_result) } ] )
✅ Yani “find_available_pets” çağrısı senin kodunda değil, modelin output’unda gerçekleşiyor. Sen sadece bu function call’u yakalayıp gerçekten çalıştırıyorsun (MCP’ye gönderiyorsun).
tam zincir:
kullanıcı → LLM → function call → MCP → sonuç → tekrar LLM
Tool tanımındaki description mı süreci etkiliyor?
Aynen öyle ✅ — tool tanımındaki description kısmı sürecin en kritik parçalarından biri.
LLM, kullanıcı mesajını alıyor → sonra kendisine senin verdiğin tool schemayı inceliyor. Tool’un adı, parametreleri ve özellikle description kısmı, modelin hangi durumda o tool’u çağıracağına karar vermesini sağlıyor.
🔎 Detaylı olarak etkileyen faktörler:
Tool adı (
name)Model için bir “anahtar kelime”.
Ama tek başına yeterli değil, çünkü kullanıcı hep “find pets” demeyebilir.
Örn: kullanıcı “show me all dogs available for adoption” derse → model description’a bakıp “bu tool adoption için available pets getiriyor” diye eşleştirir.
Description (Açıklama)
Modelin karar verme sürecinde en güçlü sinyal.
Buraya yazdığın açıklama ne kadar açık, görev tanımı ne kadar iyi olursa model o kadar doğru karar verir.
Örn:
"description": "Find pets that are currently available in the Petstore API. Use this function if the user asks about pets, animals, or available pets."Böyle yazarsan, model daha doğru tetikler.
Eğer description zayıfsa, model yanlış tool’u seçebilir ya da hiç tool çağırmayabilir.
Parameters (şema)
Modelin doğru argüman üretmesini sağlar.
Mesela enum
["available", "pending", "sold"]dersen, model bu üç değerden birini seçecektir.Bu da seni gereksiz validation’dan kurtarır.
📌 Özet:
Evet, description doğrudan etkiliyor.
Description, modelin “hangi tool ne işe yarıyor” bilgisini anlaması için kritik.
İyi yazılmış description → doğru tool seçimi ve doğru parametreler.
This server cannot be deployed
Maintenance
Related MCP Connectors
Swagger Petstore API (v1.0.27) as MCP for testing and prototyping powered by the HAPI MCP server
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for AI access to Swagger by SmartBear.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server generated from an OpenAPI specification that exposes Petstore API endpoints as tools for AI assistants. It utilizes SSE transport to enable models to interact with pet store management functionalities through natural language.-
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server that exposes Petstore API endpoints as tools for AI assistants like Claude and ChatGPT. It enables interaction with petstore management services through natural language by proxying API requests via SSE transport.-
- FlicenseNot gradedqualityDmaintenanceAn MCP server generated from an OpenAPI specification that exposes Petstore API endpoints as tools for AI assistants. It enables interaction with pet store management functionalities using the Model Context Protocol over SSE transport.-
- FlicenseNot gradedqualityDmaintenanceMCP server exposing a pet store API as tools for AI assistants, supporting HTTP operations via SSE transport.-