fastmcp
ما الذي تفعله
يرشدك إلى بناء خادم MCP بلغة Python باستخدام FastMCP، واختباره محليًا، وتثبيته في عملاء الذكاء الاصطناعي. وهو للمطورين الذين يريدون ربط أدواتهم الخاصة بمساعدي الذكاء الاصطناعي.
متى تستخدمها
- ✓عندما تريد إنشاء خادم MCP جديد بلغة Python.
- ✓عندما تريد تغليف واجهة API أو قاعدة بيانات أو أداة سطر أوامر كأدوات MCP.
- ✓عندما تريد اختبار الخادم محليًا قبل ربطه بعميل.
رابط المهارة
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/mcp/fastmcp/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“ابنِ لي خادم MCP صغيرًا بلغة Python يتيح لمساعدي الاستعلام عن قاعدة مبيعات SQLite لدينا بوضع القراءة فقط.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يبدأ وكيلك من قالب جاهز، مثل غلاف REST أو خادم قاعدة بيانات أو معالج ملفات، ثم يضيف الأدوات ويفحص الخادم بأمر FastMCP. ويمكنه بعد ذلك تثبيت الخادم في عميل مثل Claude Code.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
FastMCP
Build MCP servers in Python with FastMCP, validate them locally, install them into MCP clients, and deploy them as HTTP endpoints.
When to Use
Use this skill when the task is to:
- create a new MCP server in Python
- wrap an API, database, CLI, or file-processing workflow as MCP tools
- expose resources or prompts in addition to tools
- smoke-test a server with the FastMCP CLI before wiring it into Hermes or another client
- install a server into Claude Code, Claude Desktop, Cursor, or a similar MCP client
- prepare a FastMCP server repo for HTTP deployment
Use native-mcp when the server already exists and only needs to be connected to Hermes. Use mcporter when the goal is ad-hoc CLI access to an existing MCP server instead of building one.
Prerequisites
Install FastMCP in the working environment first:
pip install fastmcp
fastmcp version
For the API template, install httpx if it is not already present:
pip install httpx
Included Files
Templates
templates/api_wrapper.py- REST API wrapper with auth header supporttemplates/database_server.py- read-only SQLite query servertemplates/file_processor.py- text-file inspection and search server
Scripts
scripts/scaffold_fastmcp.py- copy a starter template and replace the server name placeholder
References
references/fastmcp-cli.md- FastMCP CLI workflow, installation targets, and deployment checks
Workflow
1. Pick the Smallest Viable Server Shape
Choose the narrowest useful surface area first:
- API wrapper: start with 1-3 high-value endpoints, not the whole API
- database server: expose read-only introspection and a constrained query path
- file processor: expose deterministic operations with explicit path arguments
- prompts/resources: add only when the client needs reusable prompt templates or discoverable documents
Prefer a thin server with good names, docstrings, and schemas over a large server with vague tools.
2. Scaffold from a Template
Copy a template directly or use the scaffold helper:
python ~/.hermes/skills/mcp/fastmcp/scripts/scaffold_fastmcp.py \
--template api_wrapper \
--name "Acme API" \
--output ./acme_server.py
Available templates:
python ~/.hermes/skills/mcp/fastmcp/scripts/scaffold_fastmcp.py --list
If copying manually, replace __SERVER_NAME__ with a real server name.
3. Implement Tools First
Start with @mcp.tool functions before adding resources or prompts.
Rules for tool design:
- Give every tool a concrete verb-based name
- Write docstrings as user-facing tool descriptions
- Keep parameters explicit and typed
- Return structured JSON-safe data where possible
- Validate unsafe inputs early
- Prefer read-only behavior by default for first versions
Good tool examples:
get_customersearch_ticketsdescribe_tablesummarize_text_file
Weak tool examples:
runprocessdo_thing
4. Add Resources and Prompts Only When They Help
Add @mcp.resource when the client benefits from fetching stable read-only content such as schemas, policy docs, or generated reports.
Add @mcp.prompt when the server should provide a reusable prompt template for a known workflow.
Do not turn every document into a prompt. Prefer:
- tools for actions
- resources for data/document retrieval
- prompts for reusable LLM instructions
5. Test the Server Before Integrating It Anywhere
Use the FastMCP CLI for local validation:
fastmcp inspect acme_server.py:mcp
fastmcp list acme_server.py --json
fastmcp call acme_server.py search_resources query=router limit=5 --json
For fast iterative debugging, run the server locally:
fastmcp run acme_server.py:mcp
To test HTTP transport locally:
fastmcp run acme_server.py:mcp --transport http --host 127.0.0.1 --port 8000
fastmcp list http://127.0.0.1:8000/mcp --json
fastmcp call http://127.0.0.1:8000/mcp search_resources query=router --json
Always run at least one real fastmcp call against each new tool before claiming the server works.
6. Install into a Client When Local Validation Passes
FastMCP can register the server with supported MCP clients:
fastmcp install claude-code acme_server.py
fastmcp install claude-desktop acme_server.py
fastmcp install cursor acme_server.py -e .
Use fastmcp discover to inspect named MCP servers already configured on the machine.
When the goal is Hermes
الأسئلة الشائعة
ماذا أحتاج إلى تثبيته؟
حزمة fastmcp لـ Python، تُثبَّت عبر pip، وhttpx لقالب واجهة API.
متى أستخدم native-mcp بدلًا من ذلك؟
تقول المهارة إن native-mcp يُستخدم حين يكون الخادم موجودًا ويحتاج فقط إلى ربطه بـ Hermes.
هل يمكن تشغيل الخادم عبر HTTP؟
نعم. تغطي المهارة تجهيز مستودع خادم FastMCP للنشر عبر HTTP.
التفاصيل
الشعبية
- نجوم GitHub
- 260k
- الترتيب
- #503
- الترخيص
- MIT
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
agent-merge-conflict-arbiter
260kيحسم تعارض دمج git بين فروع وكيلين كطرف محايد، فينتج نتيجة دمج واحدة للمستودع.
antigravity-cli
260kيرشدك إلى تثبيت أداة سطر أوامر Antigravity وتحديثها واستكشاف أخطائها، بما في ذلك إضافاتها وتسجيل الدخول والبيئة المعزولة.
blackbox
260kيتيح لوكيلك تسليم مهمة برمجة إلى أداة Blackbox AI لسطر الأوامر، التي تشغّل عدة نماذج ذكاء اصطناعي وتختار أفضل نتيجة.
dynamic-workflow
260kيعلّم وكيلك تشغيل مجموعات كبيرة من أعمال متشابهة كسكربت محفوظ، فلا تعود إلى المحادثة الرئيسية إلا النتائج المتحقق منها.
مهارات مشابهة
mcporter
394kيساعد وكيلك على عرض خوادم MCP وأدواتها واستدعائها وفحصها عبر HTTP أو stdio، وإدارة إعدادات تسجيل الدخول الخاصة بها.
chatgpt-app-builder
144kيساعد وكيلك على بناء تطبيقات ChatGPT فيها أدوات تفاعلية، باستخدام إطار mcp-use وOpenAI Apps SDK.
mcp-apps-builder
144kيساعد وكيلك على بناء خوادم MCP وإصلاحها، بالأدوات والموارد والأوامر والأدوات التفاعلية، وفق أفضل ممارسات إطار mcp-use.