Bir İstemci Oturumu Açma
Bir sunucuya bağlanın ve el sıkışmayı gerçekleştirin.
Bir İstemci Oturumu Açma, CoddyKit'te ücretsiz bir MCP Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, MCP Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. MCP Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
You Become the Caller
So far the server advertised tools and waited. Now you flip roles and write the client that reaches out, connects, and drives a server from your own Python code.
Same SDK, Client Side
The official mcp package you already installed ships the client too. No new dependency is needed to start connecting to servers.
from mcp import ClientSession, StdioServerParametersPick a Transport
A client first chooses how to reach the server. For a local process you use the stdio transport, talking over standard input and output.
from mcp.client.stdio import stdio_clientDescribe How to Launch It
You tell stdio exactly how to start the server with StdioServerParameters: the command to run and any arguments it needs.
params = StdioServerParameters(
command="python",
args=["server.py"],
)Open the Pipes
The stdio_client launches the server and hands you two streams, one to read replies and one to write requests. It is an async context manager.
async with stdio_client(params) as (read, write):
...Wrap Streams in a Session
Raw streams are low level, so you wrap them in a ClientSession. The session speaks JSON-RPC for you and tracks the request ids.
async with ClientSession(read, write) as session:
...Run the Handshake
Before anything else, call session.initialize(). This performs the initialize exchange so both sides agree on version and capabilities.
await session.initialize()Everything Is Async
MCP clients are built on asyncio, so your connecting code lives inside an async function and you await each network call.
import asyncio
async def main():
...
asyncio.run(main())Why a Session Object
The session is your handle for the whole conversation. Once initialized, you call methods on it to list and use what the server offers.
One Session per Server
Each server you connect to gets its own client session. To talk to several servers, you open several sessions, each over its own transport.
Clean Up Automatically
Because the session and transport are context managers, leaving the async with block shuts the server down and closes the streams for you.
Quick Check
Which call must run before you list or invoke anything?
Recap: Connecting In
You built a client: choose a transport, launch the server with parameters, wrap the streams in a session, and call initialize before doing real work.
Sıkça Sorulan Sorular
“Bir İstemci Oturumu Açma” dersi ücretsiz mi?
Evet — “Bir İstemci Oturumu Açma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve MCP Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. MCP Academy kursu toplamda 4 dersten oluşur.
“Bir İstemci Oturumu Açma” dersinde ne öğreneceğim?
Bir sunucuya bağlanın ve el sıkışmayı gerçekleştirin. MCP Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
MCP Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te MCP Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.
“Bir İstemci Oturumu Açma” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu MCP Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her MCP Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Bir İstemci Oturumu Açma
- Araçları ve Kaynakları Keşfetme
- Koddan Araç Çağırma
- Araç Çağrılarını LLM Üzerinden Yönlendirme