মূল কনটেন্টে যান

Agent MCP

বাহ্যিক Agent MCP ইন্টিগ্রেশন

বিশ্বস্ত server-side অ্যাপ্লিকেশন থেকে Manager AGI Agents-কে MCP tool হিসেবে ব্যবহার করুন। এই নির্দেশিকায় setup, authentication, downstream authorization, call, recovery এবং স্থিতিশীল ত্রুটি contract রয়েছে।

বিশ্বস্ত server-side অ্যাপ্লিকেশন থেকে Manager AGI Agents-কে MCP tool হিসেবে ব্যবহার করুন। এই নির্দেশিকায় setup, authentication, downstream authorization, call, recovery এবং স্থিতিশীল ত্রুটি contract রয়েছে।

দ্রুত শুরু

  1. Web Admin-এ সক্রিয় third-party অ্যাপ্লিকেশন তৈরি করে company যুক্ত করুন এবং App ID ও App Secret নিন।
  2. company-তে সক্রিয় Agent এবং কার্যকর published Skills assign করুন।
  3. MCP Streamable HTTP client-কে Engine HTTPS host-এর POST|GET|DELETE /openapi/v1/agents/mcp endpoint-এ যুক্ত করুন।
  4. initialize করে notifications/initialized, tools/list, তারপর agent_{id} পাঠান।

সাধারণ assistant প্রকাশিত হয় না। Secret শুধু server-এ রাখুন।

Authentication ও authority scope

API environment:

প্রতিটি অনুরোধে নিচের headers দিন:

http
Authorization: Basic Base64(KEY:SECRET)
Content-Type: application/json
Accept: application/json, text/event-stream

কাস্টম রিকোয়েস্ট হেডার সমর্থনকারী রিমোট MCP ক্লায়েন্ট নিচের কনফিগারেশন ব্যবহার করতে পারে:

json
{
  "mcpServers": {
    "manager-agi": {
      "url": "https://xxx.com/openapi/v1/agents/mcp",
      "headers": {
        "Authorization": "Basic <Base64(AppID:AppSecret)>"
      }
    }
  }
}

সক্রিয় অ্যাপ্লিকেশন company scope-এ স্থায়ী অনুমোদন পায়। এখন বা পরে assigned Agents এবং নতুন published Skills, write বা high-risk operation-সহ, human approval ছাড়াই পাওয়া যায়। CompanyRole এই authority কমায় না। Engine তবু status, assignment, publication, downstream authorization, schema/risk drift, validation, rate limit, idempotency এবং audit যাচাই করে।

Initialization ও session

initialize করে response header Mcp-Session-Id সংরক্ষণ করুন:

json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"partner-server","version":"1.0.0"}}}
json
{"jsonrpc":"2.0","method":"notifications/initialized"}

পরের POST, GET ও DELETE-এ Mcp-Session-Id পাঠান। INVALID_MCP_SESSION এলে আবার initialize করুন।

Agent tools ও metadata

json
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}

tool name হলো agent_{id} এবং prefix-এর পরে সম্পূর্ণ Agent ID থাকে। top-level title হলো Agent name; description-এ Agent description বা সেটি খালি হলে name থাকে। _meta.easyposAgent শুধু public id, name, description, iconUrl দেয়। authorizationRequirements-এ mcpHubId, mcpHubName, authType, status, expiresAt, authorized এবং authorization দরকার হলে Engine তৈরি authorizationUrl থাকে। Prompt, quick questions, Skill definitions, internal schemas বা credentials প্রকাশ পায় না।

Downstream authorization

status যখন MISSING বা REAUTH_REQUIRED, তখন Engine তৈরি authorizationUrl খুলুন; এর path /openapi/v1/mcp/authorization/start দিয়ে শুরু হয়। ব্যবহারকারী authorization শেষ করলে app আবার tools/list বা আগের tools/call চালায়; ACTIVE মানে Engine app-scoped সংরক্ষিত authorization দিয়ে execute করতে পারে। মেয়াদ শেষ হলে বা downstream 401 এলে একই flow আবার করতে হবে। token refresh, downstream header পাঠানো বা failed business call automatic replay করা যাবে না।

Agent call

json
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"agent_a441d514-2aed-4b86-b12f-7cce1bd90134","arguments":{"requestId":"req-20260825-001","message":"আজকের খোলা অর্ডারের সারাংশ দিন","conversationId":"optional-existing-id"},"_meta":{"progressToken":"req-20260825-001"}}}

requestId required, trimmed এবং সর্বোচ্চ 128 UTF-8 bytes; message required এবং সর্বোচ্চ 16 KiB; conversationId optional এবং একই অ্যাপ্লিকেশন, company ও Agent-ই reuse করতে পারে। _meta.progressToken standard MCP progress চালু করে।

সফল result-এ "status":"COMPLETED", "answer", requestId, conversationId, metadata এবং authorizationRequirements থাকে। downstream credential না থাকলে isError:true, status:"authorization_required", errorCode:"MCP_AUTHORIZATION_REQUIRED" ফেরে এবং execution তৈরি হয় না।

SSE, resume, cancellation ও close

MCP progress এবং একটি final result গ্রহণ করুন। stream recovery-তে Basic-এর সঙ্গে Mcp-Session-Id, opaque Last-Event-ID, EasyPOS-Agent-Request-Id, EasyPOS-Agent-Id এবং Accept: text/event-stream দিয়ে GET করুন। replay Agent আবার চালায় না; event বাকি থাকলে নতুন cursor দিয়ে GET করুন।

explicit MCP cancellation শুধু cancel অনুরোধ করে; dispatched side effects rollback হয় না। transport disconnect accepted work cancel করে না। Basic ও Mcp-Session-Id সহ DELETE দিয়ে session বন্ধ করুন।

Limits ও idempotency

সীমাContract
inputrequestId 128 bytes; message 16 KiB; POST 256 KiB
callsAgent MCP call-rate limit দেয় না; conversation lease, idempotency ও input-size সীমা প্রযোজ্য থাকে
retentionidempotency/replay 90 দিন
events256 stored; প্রতি GET-এ 64 returned

requestId প্রতি অ্যাপ্লিকেশনে 90 দিন idempotent। একই input নতুন execution unit ছাড়া result replay করে; ভিন্ন input IDEMPOTENCY_CONFLICT, চলমান অনুরোধ REQUEST_IN_PROGRESS দিতে পারে।

ত্রুটি contract

transport ত্রুটি HTTP এবং {"code":"COMPANY_INACTIVE","description":"The company is inactive."} ধরনের JSON দেয়। MCP/domain ত্রুটি isError:true, errorCodeerrorDescription দেয়। Description স্থিতিশীল, non-sensitive English text; program logic code-এর উপর রাখুন।

CodeReturned description
INVALID_APP_CREDENTIALSThe application credentials are missing or invalid.
APPLICATION_INACTIVEThe third-party application is inactive.
COMPANY_INACTIVEThe company is inactive.
AGENT_NOT_FOUNDThe Agent does not exist.
AGENT_NOT_ASSIGNEDThe Agent is not assigned to this company.
AGENT_DISABLEDThe Agent is disabled.
INVALID_AGENT_REQUESTThe Agent request input is missing or exceeds the supported limits.
CONVERSATION_BUSYThe conversation already has an active execution.
CONVERSATION_SCOPE_MISMATCHThe conversation does not belong to this application, company, or Agent.
MCP_AUTHORIZATION_REQUIREDRequired downstream MCP authorization is missing.
MCP_AUTHORIZATION_EXPIREDThe downstream MCP authorization has expired.
INVALID_MCP_SESSIONThe MCP session is missing, invalid, expired, or outside the application scope.
EVENT_CURSOR_SCOPE_MISMATCHThe event cursor does not belong to the requested application, Agent, or request scope.
EVENT_REPLAY_UNAVAILABLEThe requested event replay is no longer available.
ORIGIN_NOT_ALLOWEDThe request origin is not allowed for this application.
IDEMPOTENCY_CONFLICTThe requestId was already used with different input.
REQUEST_IN_PROGRESSThe idempotent request is still in progress.
SCHEMA_OR_RISK_DRIFTA Tool schema or execution-risk change requires refreshed metadata.
REQUEST_CANCELLEDThe Agent request was cancelled or exceeded its deadline.
AGENT_REQUEST_FAILEDThe previously recorded Agent request failed.
AGENT_EXECUTION_FAILEDThe Agent execution failed without a safe public detail.

নিরাপত্তা ও troubleshooting

TLS ও secret manager ব্যবহার করুন, log থেকে authorization header সরান। browser, mobile, URL বা repository-তে App Secret রাখবেন না। server client-এ Origin বাদ দিন; দিলে সেটি অনুমোদিত HTTPS origin হতে হবে। leak হলে অ্যাপ্লিকেশন disable বা Secret reset করুন।

tools/list খালি হলে company, Agent, assignment ও published Skills দেখুন। authorization প্রয়োজন হলে authorizationUrl খুলুন এবং শেষ হলে discovery বা call আবার চেষ্টা করুন; invalid session আবার initialize করুন। notification callbackUrl Agent result channel নয়; MCP/SSE থেকে result পড়ুন।