Update last Feature Completion, MCP Server ...
This commit is contained in:
@@ -0,0 +1,998 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>تحلیل تغییرات و راهنمای آزمون MCP Server با Prompt | xAiApi</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
||||
|
||||
:root {
|
||||
--primary: #1a365d;
|
||||
--primary-light: #2c5282;
|
||||
--accent: #c9a961;
|
||||
--accent-dark: #a8893f;
|
||||
--bg: #faf9f6;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1a202c;
|
||||
--text-muted: #4a5568;
|
||||
--border: #e2e8f0;
|
||||
--success: #38a169;
|
||||
--danger: #e53e3e;
|
||||
--warning: #dd6b20;
|
||||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
line-height: 1.9;
|
||||
font-size: 15px;
|
||||
padding: 30px 15px;
|
||||
}
|
||||
|
||||
.document-container {
|
||||
max-width: 1050px;
|
||||
margin: 0 auto;
|
||||
background: var(--card-bg);
|
||||
box-shadow: var(--shadow);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.document-header {
|
||||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||||
color: white;
|
||||
padding: 50px 40px 40px;
|
||||
position: relative;
|
||||
border-bottom: 4px solid var(--accent);
|
||||
}
|
||||
|
||||
.document-header::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0; right: 0;
|
||||
width: 200px; height: 200px;
|
||||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
transform: translate(50%, -50%);
|
||||
}
|
||||
|
||||
.header-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.company-badge { display: flex; align-items: center; gap: 12px; }
|
||||
|
||||
.company-logo {
|
||||
width: 60px; height: 60px;
|
||||
background: var(--accent);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.doc-meta { text-align: left; font-size: 12px; opacity: 0.9; }
|
||||
.doc-meta div { margin-bottom: 3px; }
|
||||
|
||||
.document-title { text-align: center; position: relative; z-index: 1; padding: 20px 0; }
|
||||
|
||||
.document-title .label {
|
||||
display: inline-block;
|
||||
background: rgba(201,169,97,0.2);
|
||||
color: var(--accent);
|
||||
padding: 4px 16px;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid rgba(201,169,97,0.4);
|
||||
}
|
||||
|
||||
.document-title h1 { font-size: 28px; font-weight: 800; margin-bottom: 10px; letter-spacing: -0.5px; }
|
||||
.document-title h2 { font-size: 16px; font-weight: 400; opacity: 0.9; }
|
||||
|
||||
.document-body { padding: 40px; }
|
||||
|
||||
.intro-text {
|
||||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||||
border-right: 4px solid var(--accent);
|
||||
padding: 20px 25px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 35px;
|
||||
font-size: 14px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.section { margin-bottom: 40px; page-break-inside: avoid; }
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid var(--border);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.section-number {
|
||||
width: 50px; height: 50px;
|
||||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||||
color: white;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 800;
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||||
}
|
||||
|
||||
.section-title { flex: 1; }
|
||||
.section-title h3 { font-size: 19px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
|
||||
.section-title .subtitle { font-size: 12px; color: var(--text-muted); }
|
||||
.section-content { padding-right: 10px; }
|
||||
.section-content p { margin-bottom: 12px; text-align: justify; text-indent: 20px; }
|
||||
.section-content p.no-indent { text-indent: 0; }
|
||||
|
||||
.highlight-box {
|
||||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||||
border: 1px solid #f6e05e;
|
||||
border-right: 4px solid var(--accent);
|
||||
padding: 18px 22px;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.highlight-box strong { color: var(--accent-dark); }
|
||||
|
||||
.info-box {
|
||||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||||
border: 1px solid #90cdf4;
|
||||
border-right: 4px solid var(--primary-light);
|
||||
padding: 18px 22px;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.success-box {
|
||||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||||
border: 1px solid #9ae6b4;
|
||||
border-right: 4px solid var(--success);
|
||||
padding: 18px 22px;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.warning-box {
|
||||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||||
border: 1px solid #fbd38d;
|
||||
border-right: 4px solid var(--warning);
|
||||
padding: 18px 22px;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.styled-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 20px 0;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.styled-table thead { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
|
||||
.styled-table th { padding: 14px 16px; text-align: right; font-weight: 600; font-size: 13px; }
|
||||
.styled-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
|
||||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||||
.styled-table .highlight-row { background: #fffaf0 !important; font-weight: 600; }
|
||||
|
||||
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 25px 0; }
|
||||
|
||||
.comparison-card {
|
||||
background: #f8fafc;
|
||||
border: 2px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.comparison-card.recommended {
|
||||
border-color: var(--success);
|
||||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||||
}
|
||||
|
||||
.comparison-card .card-badge {
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
right: 20px;
|
||||
background: var(--success);
|
||||
color: white;
|
||||
padding: 3px 12px;
|
||||
border-radius: 15px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.comparison-card h4 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.comparison-card.recommended h4 { border-bottom-color: var(--success); }
|
||||
.comparison-card ul { list-style: none; padding: 0; }
|
||||
.comparison-card ul li {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
.comparison-card ul li:last-child { border-bottom: none; }
|
||||
.comparison-card ul li .value { font-weight: 600; color: var(--primary); }
|
||||
|
||||
.quote-box {
|
||||
background: linear-gradient(135deg, #f7fafc, #edf2f7);
|
||||
border-right: 4px solid var(--accent);
|
||||
padding: 20px 25px;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.quote-box::before {
|
||||
content: '"';
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
right: 15px;
|
||||
font-size: 60px;
|
||||
color: var(--accent);
|
||||
opacity: 0.3;
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
|
||||
.quote-box p { font-style: italic; color: var(--text-muted); margin-bottom: 10px; text-indent: 0 !important; }
|
||||
.quote-box .source { font-size: 12px; color: var(--text-muted); text-align: left; font-style: normal; }
|
||||
|
||||
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: 25px 0; }
|
||||
|
||||
.stat-card {
|
||||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||||
color: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
|
||||
}
|
||||
|
||||
.stat-card .stat-value { font-size: 24px; font-weight: 800; margin-bottom: 5px; color: var(--accent); line-height: 1.3; }
|
||||
.stat-card .stat-label { font-size: 12px; opacity: 0.9; }
|
||||
|
||||
.timeline { position: relative; padding: 20px 0; margin: 25px 0; }
|
||||
|
||||
.timeline::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 50%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 3px;
|
||||
background: var(--border);
|
||||
transform: translateX(50%);
|
||||
}
|
||||
|
||||
.timeline-item { display: flex; margin-bottom: 20px; position: relative; }
|
||||
.timeline-item:nth-child(odd) { flex-direction: row-reverse; }
|
||||
|
||||
.timeline-content {
|
||||
width: 45%;
|
||||
background: #f8fafc;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.timeline-item:nth-child(odd) .timeline-content { margin-left: 5%; }
|
||||
.timeline-item:nth-child(even) .timeline-content { margin-right: 5%; }
|
||||
|
||||
.timeline-dot {
|
||||
position: absolute;
|
||||
right: 50%;
|
||||
top: 20px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: var(--accent);
|
||||
border: 3px solid white;
|
||||
border-radius: 50%;
|
||||
transform: translateX(50%);
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.timeline-content h5 { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
|
||||
.timeline-content p { font-size: 12px; color: var(--text-muted); text-indent: 0 !important; margin-bottom: 0 !important; }
|
||||
|
||||
.reference-list { list-style: none; padding: 0; margin: 20px 0; }
|
||||
.reference-list li {
|
||||
background: #f8fafc;
|
||||
border-right: 3px solid var(--primary-light);
|
||||
padding: 15px 20px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.reference-list li strong { color: var(--primary); display: block; margin-bottom: 5px; }
|
||||
.reference-list li .ref-source { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
|
||||
|
||||
.conclusion-box {
|
||||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||||
color: white;
|
||||
padding: 30px;
|
||||
border-radius: 12px;
|
||||
margin: 30px 0;
|
||||
text-align: center;
|
||||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||||
}
|
||||
|
||||
.conclusion-box h3 { font-size: 22px; font-weight: 800; margin-bottom: 15px; color: var(--accent); }
|
||||
.conclusion-box p { font-size: 14px; line-height: 1.8; text-indent: 0 !important; margin-bottom: 15px; }
|
||||
.conclusion-box .highlight {
|
||||
background: rgba(201,169,97,0.2);
|
||||
padding: 15px 20px;
|
||||
border-radius: 8px;
|
||||
margin-top: 20px;
|
||||
border: 1px solid rgba(201,169,97,0.4);
|
||||
}
|
||||
|
||||
.document-footer {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
padding: 25px 40px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.document-footer .footer-brand { font-weight: 700; color: var(--accent); margin-bottom: 5px; font-size: 14px; }
|
||||
.footer-divider { width: 60px; height: 2px; background: var(--accent); margin: 10px auto; }
|
||||
|
||||
.page-info {
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: #0b1220;
|
||||
color: #e2e8f0;
|
||||
padding: 16px 18px;
|
||||
border-radius: 8px;
|
||||
overflow: auto;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
font-family: Consolas, Monaco, 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.65;
|
||||
margin: 15px 0;
|
||||
border: 1px solid #1e293b;
|
||||
}
|
||||
|
||||
.prompt-box {
|
||||
background: #0f172a;
|
||||
color: #f8fafc;
|
||||
border-right: 4px solid var(--accent);
|
||||
padding: 16px 20px;
|
||||
border-radius: 8px;
|
||||
margin: 15px 0;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
font-family: Consolas, Monaco, 'Courier New', monospace;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.7;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.prompt-box.fa {
|
||||
direction: rtl;
|
||||
text-align: right;
|
||||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tag {
|
||||
display: inline-block;
|
||||
background: #edf2f7;
|
||||
color: var(--primary);
|
||||
padding: 1px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body { background: white; padding: 0; }
|
||||
.document-container { box-shadow: none; border-radius: 0; }
|
||||
.section { page-break-inside: avoid; }
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.document-body { padding: 25px 20px; }
|
||||
.document-header { padding: 30px 20px; }
|
||||
.comparison-grid { grid-template-columns: 1fr; }
|
||||
.stats-grid { grid-template-columns: 1fr; }
|
||||
.header-top { flex-direction: column; gap: 15px; }
|
||||
.doc-meta { text-align: center; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="document-container">
|
||||
|
||||
<header class="document-header">
|
||||
<div class="header-top">
|
||||
<div class="company-badge">
|
||||
<div class="company-logo"></div>
|
||||
</div>
|
||||
<div class="doc-meta">
|
||||
<div>شماره مستند: MCP-1405-002</div>
|
||||
<div>نسخه: ۱.۰</div>
|
||||
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
|
||||
<div>طبقهبندی: فنی / محرمانه</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-title">
|
||||
<span class="label">TECHNICAL ANALYSIS & TEST GUIDE</span>
|
||||
<h1>تحلیل تغییرات و راهنمای آزمون MCP Server با Prompt</h1>
|
||||
<h2>بررسی یکپارچگی MCP در xAiApi، xAiMcpServer، xAiModels و xAiService</h2>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="document-body">
|
||||
|
||||
<div class="intro-text">
|
||||
<strong>خلاصه هدف:</strong><br>
|
||||
این مستند بر اساس فایلهای ارائهشده، تغییرات و قابلیتهای مرتبط با MCP Server را تحلیل میکند و سپس یک مسیر عملی و گامبهگام برای آزمون استفاده از ابزارهای MCP توسط مدل زبانی از طریق Prompt ارائه میدهد. تمرکز اصلی روی این پرسش است: «چگونه مطمئن شویم مدل، ابزار MCP را در پاسخ به یک Prompt واقعاً فراخوانی میکند؟»
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۱</div>
|
||||
<div class="section-title">
|
||||
<h3>خلاصه اجرایی</h3>
|
||||
<div class="subtitle">Executive Summary</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>در کد ارائهشده، MCP در دو نقش مستقل پیادهسازی شده است:</p>
|
||||
|
||||
<div class="comparison-grid">
|
||||
<div class="comparison-card recommended">
|
||||
<span class="card-badge">MCP Client / Manager</span>
|
||||
<h4>xAiApi</h4>
|
||||
<ul>
|
||||
<li><span>وظیفه</span> <span class="value">مدیریت MCP Serverها و ابزارها</span></li>
|
||||
<li><span>کلیدواژه</span> <span class="value">XAiMcpServerProvider</span></li>
|
||||
<li><span>اتصال</span> <span class="value">ModelContextProtocol.Client</span></li>
|
||||
<li><span>خروجی</span> <span class="value">McpClientTool → ChatOptions.Tools</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="comparison-card">
|
||||
<h4>xAiMcpServer</h4>
|
||||
<ul>
|
||||
<li><span>وظیفه</span> <span class="value">ارائه MCP Server نمونه</span></li>
|
||||
<li><span>کلیدواژه</span> <span class="value">XAiMcpHandler / XAiMcpToolScanner</span></li>
|
||||
<li><span>مسیر</span> <span class="value">POST /mcp</span></li>
|
||||
<li><span>ابزار نمونه</span> <span class="value">XEchoTools.Echo</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="success-box">
|
||||
<strong>نتیجه کلیدی:</strong> برای آزمون با Prompt، باید ابتدا یک MCP Server در xAiApi ثبت و فعال شود، سپس از یکی از Endpointهای AI مانند <span class="tag">POST /api/v1/XAi/Ask</span> استفاده شود. مدل با دیدن ابزارهای MCP در <code>ChatOptions.Tools</code> و با دستور صریح در Prompt، ابزار را فراخوانی میکند. ابزار نمونه <code>Echo</code> مقدار <code>hello {message}</code> را برمیگرداند؛ بنابراین با یک پیام یکتا میتوان صحت فراخوانی را تشخیص داد.
|
||||
</div>
|
||||
|
||||
<div class="highlight-box">
|
||||
<strong>نکته مهم:</strong> خود Prompt بهتنهایی جادو نمیکند. سه شرط باید همزمان برقرار باشد: (۱) MCP Server متصل و ابزارها کشف شده باشند، (۲) مدل انتخابی از Function Calling / Tool Calling پشتیبانی کند، (۳) Prompt صریحاً به استفاده از ابزار اشاره کند.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۲</div>
|
||||
<div class="section-title">
|
||||
<h3>تحلیل تغییرات کلیدی</h3>
|
||||
<div class="subtitle">Key Changes Analysis</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>بر اساس فایلهای ارائهشده، تغییرات و قابلیتهای زیر قابل مشاهده است:</p>
|
||||
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ماژول / بخش</th>
|
||||
<th>تغییر یا قابلیت کلیدی</th>
|
||||
<th>اثر عملی</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>xAiApi</strong></td>
|
||||
<td>افزودن <code>McpServersController</code>، <code>XAiMcpServerProvider</code>، DI مربوطه و جدول <code>AiMcpServers</code> در Migration</td>
|
||||
<td>CRUD، Enable/Disable/Toggle، Query و Refresh برای MCP Serverها؛ اتصال به MCP Server و کشف ابزارها</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>xAiApi / XAIServiceBase</strong></td>
|
||||
<td>تزریق <code>IXAiMcpServerProvider</code> و افزودن ابزارهای MCP به <code>ChatOptions.Tools</code></td>
|
||||
<td>مدل زبانی در زمان پاسخدهی، ابزارهای MCP را بهعنوان Tool میبیند و میتواند آنها را فراخوانی کند</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>xAiApi / XModelsExtensions</strong></td>
|
||||
<td>ساخت ChatClient با <code>UseFunctionInvocation()</code></td>
|
||||
<td>زیرساخت اجرای Tool Call در سمت کلاینت فراهم شده است</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>xAiModels</strong></td>
|
||||
<td>افزودن Attributeهای <code>XAiMcpToolType</code>، <code>XAiMcpTool</code>، <code>XAiMcpToolParam</code>؛ Entity/DTO مربوط به MCP Server؛ Scope استفاده</td>
|
||||
<td>تعریف ابزارها بهصورت Declarative و مدیریت دسترسی Owner/All</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>xAiService</strong></td>
|
||||
<td>افزودن <code>XAiMcpHandler</code>، <code>XAiMcpToolScanner</code>، <code>XAiMcpToolBlueprint</code> و <code>XAiMcpControllerBase</code></td>
|
||||
<td>پیادهسازی JSON-RPC MCP شامل <code>initialize</code>، <code>tools/list</code>، <code>tools/call</code> و <code>ping</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>xAiMcpServer</strong></td>
|
||||
<td>پروژه Host مستقل MCP Server، کنترلر <code>/mcp</code> و ابزار نمونه <code>XEchoTools</code></td>
|
||||
<td>امکان اجرای یک MCP Server واقعی برای تست End-to-End</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>RAG / Knowledge / ChatWithDocuments</strong></td>
|
||||
<td>افزودن سرویسهای RAG، Vector Store، Text Chunker و Extractors</td>
|
||||
<td>خارج از تمرکز این مستند، اما از همان مسیر <code>XAIServiceBase</code> برای ابزارهای MCP استفاده میکنند</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">جریان فنی MCP در xAiApi</h4>
|
||||
|
||||
<div class="timeline">
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-dot"></div>
|
||||
<div class="timeline-content">
|
||||
<h5>۱. ثبت MCP Server</h5>
|
||||
<p>از طریق <code>POST /api/v1/McpServers</code> یک رکورد با Endpoint، Headers، Timeout و Scope ایجاد میشود.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-dot"></div>
|
||||
<div class="timeline-content">
|
||||
<h5>۲. اتصال و کشف ابزار</h5>
|
||||
<p><code>XAiMcpServerProvider.ConnectAndValidateAsync</code> با <code>McpClient</code> به Endpoint وصل شده و <code>ListToolsAsync</code> را اجرا میکند.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-dot"></div>
|
||||
<div class="timeline-content">
|
||||
<h5>۳. تزریق ابزارها به مدل</h5>
|
||||
<p>در <code>XAIServiceBase</code> متد <code>GetAvailableToolsAsync</code> فراخوانی و نتیجه به <code>Options.Tools</code> اضافه میشود.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-dot"></div>
|
||||
<div class="timeline-content">
|
||||
<h5>۴. فراخوانی توسط مدل</h5>
|
||||
<p>مدل بر اساس Prompt و Description ابزار، Tool Call تولید میکند. <code>UseFunctionInvocation</code> اجرای آن را مدیریت میکند.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-dot"></div>
|
||||
<div class="timeline-content">
|
||||
<h5>۵. بازگشت نتیجه ابزار</h5>
|
||||
<p>نتیجه اجرای ابزار به مدل برمیگردد و پاسخ نهایی در <code>Ask</code> یا <code>AskStream</code> به کاربر نمایش داده میشود.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="warning-box">
|
||||
<strong>نکته فنی قابل توجه:</strong> در <code>GetAvailableToolsAsync</code>، در اولین مقداردهی (<code>isInitialized == false</code>) خروجی نهایی همه ابزارهای متصل را برمیگرداند و فیلترینگ Owner/All فقط در فراخوانیهای بعدی اعمال میشود. برای محیط چندکاربره، بهتر است این رفتار بازبینی و اصلاح شود.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۳</div>
|
||||
<div class="section-title">
|
||||
<h3>پیشنیازهای آزمون با Prompt</h3>
|
||||
<div class="subtitle">Prerequisites</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>قبل از آزمون Prompt، موارد زیر را کنترل کنید:</p>
|
||||
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>پیشنیاز</th>
|
||||
<th>توضیح</th>
|
||||
<th>نشانه عدم برقراری</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>اجرای xAiMcpServer</td>
|
||||
<td>پروژه MCP Server باید در حال اجرا باشد و مسیر <code>POST /mcp</code> پاسخ دهد.</td>
|
||||
<td>خطای Connection refused یا Timeout در xAiApi</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>دسترسی شبکه و گواهی</td>
|
||||
<td>xAiApi باید بتواند Endpoint را صدا بزند. برای HTTPS از گواهی معتبر یا Dev Certificate استفاده کنید.</td>
|
||||
<td>خطای SSL / Certificate Validation در لاگ اتصال MCP</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ثبت و فعال بودن MCP Server</td>
|
||||
<td>رکورد MCP Server در xAiApi ایجاد و <code>Enabled = true</code> باشد.</td>
|
||||
<td><code>GetAvailableToolsAsync</code> خالی برمیگردد</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>دسترسی کاربر</td>
|
||||
<td>کاربر غیرادمین فقط MCP Serverهای Owner خودش را میبیند. برای Scope=All نیاز به ادمین است.</td>
|
||||
<td>ابزار در لیست نیست، اما رکورد در DB وجود دارد</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>مدل با پشتیبانی Tool Calling</td>
|
||||
<td>مدل انتخابی باید Function Calling را پشتیبانی کند. مدلهای ضعیف ممکن است ابزار را نادیده بگیرند.</td>
|
||||
<td>پاسخ متنی بدون فراخوانی ابزار</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Prompt صریح</td>
|
||||
<td>در Prompt نام ابزار و ورودی آن را مشخص کنید و از مدل بخواهید خروجی ابزار را برگرداند.</td>
|
||||
<td>مدل از حافظه پاسخ میدهد یا ابزار را نادیده میگیرد</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="info-box">
|
||||
<strong>نکته درباره Scope:</strong> در enum <code>XAiMcpServerUsageScope</code> مقدار <code>All = 1</code> و <code>Owner = 2</code> است. در Add/Update، اگر کاربر ادمین نباشد، Scope بهصورت خودکار روی <code>Owner</code> تنظیم میشود. مقدار پیشفرض Entity نیز <code>Owner</code> است.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۴</div>
|
||||
<div class="section-title">
|
||||
<h3>آزمون مستقیم MCP Server با JSON-RPC</h3>
|
||||
<div class="subtitle">Direct MCP Server Test</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>قبل از آزمون با Prompt، ابتدا مطمئن شوید خود MCP Server درست کار میکند. مسیر پیشفرض در <code>XAiMcpControllerBase</code> برابر <code>/mcp</code> است و متد <code>POST</code> را میپذیرد. اگر سرور روی <code>https://localhost:7001</code> اجرا شده باشد:</p>
|
||||
|
||||
<div class="code-block">curl -k -X POST "https://localhost:7001/mcp" ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"curl-test\",\"version\":\"1.0\"}}}"</div>
|
||||
|
||||
<p>سپس لیست ابزارها را بگیرید:</p>
|
||||
|
||||
<div class="code-block">curl -k -X POST "https://localhost:7001/mcp" ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/list\",\"params\":{}}"</div>
|
||||
|
||||
<p>باید ابزار <code>Echo</code> را در خروجی ببینید. سپس آن را فراخوانی کنید:</p>
|
||||
|
||||
<div class="code-block">curl -k -X POST "https://localhost:7001/mcp" ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"Echo\",\"arguments\":{\"message\":\"MCP-Direct-Test-1405\"}}}"</div>
|
||||
|
||||
<div class="success-box">
|
||||
<strong>خروجی مورد انتظار:</strong> در <code>result.content[0].text</code> مقدار <code>hello MCP-Direct-Test-1405</code> برگردد. اگر این مرحله موفق شد، زیرساخت MCP Server سالم است و مشکل احتمالی بعدی مربوط به اتصال xAiApi یا Prompt است.
|
||||
</div>
|
||||
|
||||
<p class="no-indent">روشهای پشتیبانیشده در <code>XAiMcpHandler</code>:</p>
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr><th>متد JSON-RPC</th><th>کارکرد</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td><code>initialize</code></td><td>بازگرداندن protocolVersion، capabilities و serverInfo</td></tr>
|
||||
<tr><td><code>tools/list</code></td><td>لیست ابزارهای کشفشده با name، description و inputSchema</td></tr>
|
||||
<tr><td><code>tools/call</code></td><td>اجرای ابزار با name و arguments</td></tr>
|
||||
<tr><td><code>ping</code></td><td>پاسخ ساده برای بررسی سلامت</td></tr>
|
||||
<tr><td>سایر متدها</td><td>خطای <code>-32601 Method not found</code></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۵</div>
|
||||
<div class="section-title">
|
||||
<h3>ثبت MCP Server در xAiApi و آزمون با Prompt</h3>
|
||||
<div class="subtitle">Register in xAiApi & Prompt Test</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>برای آزمون اصلی، MCP Server را در xAiApi ثبت کنید. مسیرهای زیر بر اساس الگوی <code>XBaseIdentityApiV1Controller</code> است؛ مسیر دقیق را در Swagger تأیید کنید. معمولاً بهصورت <code>/api/v1/McpServers</code> و <code>/api/v1/XAi/Ask</code> است.</p>
|
||||
|
||||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۱: ثبت MCP Server</h4>
|
||||
|
||||
<div class="code-block">POST /api/v1/McpServers
|
||||
Authorization: Bearer <ACCESS_TOKEN>
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "Local Echo MCP",
|
||||
"description": "Echo tool for MCP prompt test",
|
||||
"endpoint": "https://localhost:7001/mcp",
|
||||
"headers": "{}",
|
||||
"timeoutSeconds": 30,
|
||||
"enabled": true,
|
||||
"scope": 2
|
||||
}</div>
|
||||
|
||||
<p class="no-indent"><span class="tag">scope = 2</span> یعنی <code>Owner</code> و <span class="tag">scope = 1</span> یعنی <code>All</code>. اگر Swagger مقدار رشتهای نشان میدهد، از همان مقدار استفاده کنید. برای Headers احراز هویت، یک JSON String بدهید؛ مثلاً:</p>
|
||||
|
||||
<div class="code-block">"headers": "{\"Authorization\":\"Bearer YOUR_MCP_TOKEN\"}"</div>
|
||||
|
||||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۲: بررسی، فعالسازی و Refresh</h4>
|
||||
|
||||
<div class="code-block">GET /api/v1/McpServers?forceOwner=true
|
||||
Authorization: Bearer <ACCESS_TOKEN>
|
||||
|
||||
POST /api/v1/McpServers/{id}/Enable
|
||||
Authorization: Bearer <ACCESS_TOKEN>
|
||||
|
||||
POST /api/v1/McpServers/Refresh
|
||||
Authorization: Bearer <ADMIN_TOKEN></div>
|
||||
|
||||
<div class="info-box">
|
||||
<strong>Refresh چه زمانی لازم است؟</strong> وقتی MCP Server بعد از راهاندازی xAiApi بالا آمده باشد، یا ابزارهای سمت سرور تغییر کرده باشند. <code>Refresh</code> کلاینتها و کش ابزارها را پاک و مجدداً مقداردهی میکند. این Endpoint نیاز به نقش ادمین دارد.
|
||||
</div>
|
||||
|
||||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۳: ارسال Prompt صریح</h4>
|
||||
|
||||
<p>اکنون از یکی از Endpointهای AI استفاده کنید. بهترین گزینه برای تست سریع، <code>POST /api/v1/XAi/Ask</code> است:</p>
|
||||
|
||||
<div class="code-block">POST /api/v1/XAi/Ask
|
||||
Authorization: Bearer <ACCESS_TOKEN>
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"prompt": "Use the Echo tool from the connected MCP server. Call it with {\"message\":\"MCP-Prompt-Test-1405-01\"} and return exactly the tool output. Do not answer from memory.",
|
||||
"type": "XAiKnowledge",
|
||||
"topK": 5
|
||||
}</div>
|
||||
|
||||
<p>برای مدلهایی که با فارسی بهتر Tool Call میکنند، از Prompt فارسی صریح استفاده کنید:</p>
|
||||
|
||||
<div class="prompt-box fa">
|
||||
از ابزار Echo استفاده کن و ورودی آن را {"message":"MCP-Prompt-Test-1405-01"} قرار بده. فقط و فقط خروجی دقیق ابزار را برگردان و از حافظه پاسخ نده.
|
||||
</div>
|
||||
|
||||
<div class="success-box">
|
||||
<strong>پاسخ مورد انتظار:</strong> پاسخ نهایی باید شامل <code>hello MCP-Prompt-Test-1405-01</code> باشد. چون این مقدار یکتا است، اگر مدل دقیقاً همین را برگرداند، احتمال بسیار زیاد ابزار <code>Echo</code> واقعاً اجرا شده است. برای اطمینان بیشتر، همزمان لاگهای xAiApi و xAiMcpServer را بررسی کنید.
|
||||
</div>
|
||||
|
||||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۴: آزمون Streaming</h4>
|
||||
|
||||
<p>برای آزمون جریان پاسخ، از <code>AskStream</code> استفاده کنید. خروجی SSE است و در نهایت پاسخ مدل را نشان میدهد:</p>
|
||||
|
||||
<div class="code-block">POST /api/v1/XAi/AskStream
|
||||
Authorization: Bearer <ACCESS_TOKEN>
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"prompt": "Call the Echo MCP tool with message=\"MCP-Stream-Test-1405\". Return only the exact tool output.",
|
||||
"type": "XAiKnowledge"
|
||||
}</div>
|
||||
|
||||
<div class="highlight-box">
|
||||
<strong>مهم:</strong> اگر مدل از Tool Calling پشتیبانی نکند یا Prompt صریح نباشد، ممکن است پاسخ متنی تولید کند و ابزار را فراخوانی نکند. در این حالت، پاسخ شامل مقدار یکتا نخواهد بود یا مقدار را از خود میسازد. آزمون مستقیم JSON-RPC و استفاده از پیام یکتا، بهترین راه تفکیک این حالت است.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۶</div>
|
||||
<div class="section-title">
|
||||
<h3>سناریوهای تست پیشنهادی</h3>
|
||||
<div class="subtitle">Recommended Test Scenarios</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>سناریو</th>
|
||||
<th>Prompt</th>
|
||||
<th>انتظار</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>تست پایه Tool Call</td>
|
||||
<td>Use the Echo tool with message="TEST-001" and return exactly the output.</td>
|
||||
<td>پاسخ شامل <code>hello TEST-001</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>تست فارسی</td>
|
||||
<td>از ابزار Echo استفاده کن و message را "TEST-002" بگذار؛ فقط خروجی ابزار را برگردان.</td>
|
||||
<td>پاسخ شامل <code>hello TEST-002</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>تست عدم استفاده از ابزار</td>
|
||||
<td>بدون استفاده از هیچ ابزاری، حاصل ۲+۲ را بگو.</td>
|
||||
<td>پاسخ <code>4</code> بدون فراخوانی ابزار</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>تست ابزار ناموجود</td>
|
||||
<td>از ابزار NotExists استفاده کن.</td>
|
||||
<td>مدل باید عدم وجود ابزار را بیان کند یا از ابزار موجود استفاده نکند</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>تست پس از Refresh</td>
|
||||
<td>بعد از <code>POST /McpServers/Refresh</code> همان Prompt پایه را تکرار کنید.</td>
|
||||
<td>ابزارها مجدداً کشف شوند و پاسخ موفق باشد</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="quote-box">
|
||||
<p>بهترین روش برای اثبات واقعی بودن Tool Call، استفاده از یک مقدار یکتا در ورودی ابزار و بررسی بازگشت دقیق همان مقدار توسط ابزار است. صرفاً دیدن نام ابزار در پاسخ مدل، اثبات اجرای واقعی نیست.</p>
|
||||
<div class="source">— راهنمای عملی آزمون MCP</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۷</div>
|
||||
<div class="section-title">
|
||||
<h3>عیبیابی خطاهای رایج</h3>
|
||||
<div class="subtitle">Troubleshooting</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>علامت</th>
|
||||
<th>علت احتمالی</th>
|
||||
<th>اقدام</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>ابزارها خالی هستند</td>
|
||||
<td>MCP Server غیرفعال است، اتصال برقرار نشده، یا Endpoint اشتباه است</td>
|
||||
<td>Endpoint را با curl تست کنید؛ رکورد را Enable کنید؛ <code>POST /McpServers/Refresh</code> بزنید</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>خطای SSL / Certificate</td>
|
||||
<td>گواهی self-signed است و کلاینت MCP اعتبارسنجی میکند</td>
|
||||
<td>از گواهی معتبر یا Dev Certificate استفاده کنید؛ در کد فعلی برای MCP کلاینت Bypass SSL تنظیم نشده است</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ابزار برای کاربر غیرادمین دیده نمیشود</td>
|
||||
<td>Scope روی Owner است و OwnerId با کاربر جاری یکی نیست</td>
|
||||
<td>با همان کاربری که رکورد را ساخته تست کنید یا با ادمین Scope=All ثبت کنید</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>مدل ابزار را صدا نمیزند</td>
|
||||
<td>مدل Tool Calling را پشتیبانی نمیکند یا Prompt صریح نیست</td>
|
||||
<td>مدل مناسب انتخاب کنید؛ Prompt انگلیسی صریح با نام ابزار و ورودی دقیق بدهید</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>پاسخ شبیه خروجی ابزار است اما مطمئن نیستیم</td>
|
||||
<td>مدل ممکن است مقدار را از حافظه بسازد</td>
|
||||
<td>مقدار یکتا بدهید؛ لاگ MCP Server را بررسی کنید؛ مستقیم <code>tools/call</code> بزنید</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>بعد از تغییر ابزارها هنوز قدیمی است</td>
|
||||
<td>کش <code>tools</code> در Provider بهروز نشده</td>
|
||||
<td><code>POST /api/v1/McpServers/Refresh</code> با توکن ادمین</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Timeout در اتصال</td>
|
||||
<td>Timeout کمتر از حداقل یا شبکه کند است</td>
|
||||
<td><code>TimeoutSeconds</code> را حداقل ۳۰ و مناسب تنظیم کنید</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="warning-box">
|
||||
<strong>نکته امنیتی:</strong> در محیط عملیاتی، Endpointهای MCP را بدون احراز هویت و بدون محدودیت شبکه منتشر نکنید. از Headers معتبر، TLS، محدودیت IP و Scope مناسب استفاده کنید. همچنین خروجی ابزارها را قبل از بازگرداندن به مدل، از نظر حساسیت داده بررسی کنید.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<div class="section-number">۸</div>
|
||||
<div class="section-title">
|
||||
<h3>جمعبندی و پیشنهاد نهایی</h3>
|
||||
<div class="subtitle">Final Summary & Recommendation</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<p>یکپارچگی MCP در کد ارائهشده کامل و قابل استفاده است: xAiMcpServer یک MCP Server واقعی با ابزار <code>Echo</code> ارائه میدهد، xAiService هندلر JSON-RPC و Scanner را پیادهسازی کرده، و xAiApi بهعنوان MCP Client ابزارها را کشف و به مدل تزریق میکند.</p>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">۱</div>
|
||||
<div class="stat-label">ابتدا MCP Server را مستقیم با JSON-RPC تست کنید</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">۲</div>
|
||||
<div class="stat-label">سپس MCP Server را در xAiApi ثبت و Refresh کنید</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">۳</div>
|
||||
<div class="stat-label">در نهایت با Prompt صریح و مقدار یکتا Tool Call را بسنجید</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="conclusion-box">
|
||||
<h3>🎯 پیشنهاد نهایی</h3>
|
||||
<p>برای آزمون استفاده از MCP Server با Prompt، مسیر زیر را طی کنید:</p>
|
||||
<p><strong>اجرای xAiMcpServer → تست مستقیم <code>tools/list</code> و <code>tools/call</code> → ثبت MCP Server در xAiApi → Enable و Refresh → ارسال Prompt صریح به <code>/api/v1/XAi/Ask</code> با پیام یکتا → بررسی بازگشت <code>hello <unique-message></code>.</strong></p>
|
||||
<div class="highlight">
|
||||
<strong>💎 معیار موفقیت:</strong><br>
|
||||
بازگشت دقیق مقدار یکتای ورودی ابزار در پاسخ نهایی + مشاهده ابزار در <code>tools/list</code> + عدم خطای اتصال در لاگها.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-box">
|
||||
<strong>گام بعدی پیشنهادی:</strong> در صورت نیاز به تست چندابزاری، یک ابزار جدید با <code>[XAiMcpToolType]</code> و <code>[XAiMcpTool]</code> در xAiMcpServer اضافه کنید، سرویس را ریاستارت و در xAiApi <code>Refresh</code> بزنید. سپس Prompt را طوری بنویسید که مدل بین دو ابزار انتخاب کند تا کیفیت Tool Selection نیز سنجیده شود.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-info">
|
||||
این مستند فنی و محرمانه است و صرفاً برای تحلیل و آزمون یکپارچگی MCP در مجموعه xSaherelmWorkspace تهیه شده است.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="document-footer">
|
||||
<div class="footer-brand">تحلیل فنی: تیم معماری xSaherelmWorkspace</div>
|
||||
<div class="footer-divider"></div>
|
||||
<div>تاریخ تهیه: آبان ۱۴۰۵ | نسخه: ۱.۰ | طبقهبندی: فنی / محرمانه</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user