0Pricing
MCP Academy · درس

إضافة Python SDK الخاص بـMCP

أضيفوا الحزمة الرسمية mcp إلى مشروعكم.

إضافة Python SDK الخاص بـMCP درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MCP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MCP Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Time to Add the SDK

Your project is scaffolded, but it can't speak MCP yet. The next step is pulling in the official library that does all the heavy lifting. 📦

The Package Is Just mcp

The official Python SDK ships as a package simply named mcp. It contains everything you need to build servers and clients in plain Python.

Add It with uv

Inside your project folder, run uv add to install the SDK and record it as a dependency. One command grabs it and updates your project files.

uv add "mcp[cli]"

Why the [cli] Extra

The [cli] extra adds the command-line tools that run and inspect servers. Without it you get the library but miss the handy mcp commands.

Quote the Brackets

Always wrap the name in quotes, like "mcp[cli]". Many shells treat square brackets as special characters, and quotes keep them literal.

pip Still Works Too

If you prefer plain pip, the same package installs the same way. Either tool gives you an identical SDK, so pick whichever fits your workflow.

pip install "mcp[cli]"

It Records the Dependency

uv add doesn't just install; it writes mcp into your pyproject.toml. Anyone who clones your project gets the exact same requirement.

The Lockfile Pins Versions

uv also updates a uv.lock file that pins the exact resolved versions. That makes your installs reproducible on any machine, every time.

Confirm the Import

Verify the install worked by importing the SDK inside your environment. If nothing errors out, the mcp package is ready to use.

uv run python -c "import mcp; print('ok')"

Where the Server Lives

The class you'll use most is FastMCP, found under mcp.server.fastmcp. It's the high-level way to define tools without touching raw protocol details.

from mcp.server.fastmcp import FastMCP

One Import, Big Power

That single import unlocks decorators for tools, resources, and prompts. The SDK turns ordinary Python functions into capabilities an AI can call. ✨

Quick Check

You want the SDK plus its command-line helpers.

The SDK Is In

You added mcp[cli], recorded it in pyproject.toml, locked the versions, and confirmed the import. Your project can now build a real MCP server. 🎯

الأسئلة الشائعة

هل درس «إضافة Python SDK الخاص بـMCP» مجاني؟

نعم — نص درس «إضافة Python SDK الخاص بـMCP» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.

ماذا ستتعلم في «إضافة Python SDK الخاص بـMCP»؟

أضيفوا الحزمة الرسمية mcp إلى مشروعكم. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟

لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «إضافة Python SDK الخاص بـMCP»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟

نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. تثبيت Python وuv
  2. إضافة Python SDK الخاص بـMCP
  3. التعرّف على mcp CLI
  4. تخطيط مشروع الخادم
← العودة إلى MCP Academy