AS AgentScopeAPI 手册 / API Reference

McpMeta

public record McpMeta(Map<String, Object> entries)
源码Source io/agentscope/core/tool/mcp/McpMeta.java:55–121

承载 MCP 元数据数据的记录类型。位于 io.agentscope.core.tool.mcp 包。核心成员包括 entries、isEmpty、merge、equals、toString、McpMeta。

Type-namespace marker for MCP (Model Context Protocol) request metadata.

Register an instance of this class in a RuntimeContext (via RuntimeContext or RuntimeContext) to have its entries automatically included as the meta field of every MCP McpSchema.CallToolRequest sent through McpTool.

Only objects registered under the McpMeta.class type key are extracted — other context objects (DI beans, configs, etc.) are never leaked into MCP meta.

Usage examples:

1) Via RuntimeContext:

`RuntimeContext rtCtx = RuntimeContext.builder()
.put(McpMeta.class, new McpMeta(Map.of("traceId", "abc-123")))
.build();
`

2) Merging multiple meta sources (later entries override earlier ones for the same key):

`McpMeta base = new McpMeta(Map.of("traceId", "abc-123"));
McpMeta extra = new McpMeta(Map.of("callbackUrl", "https://hook.example.com"));
McpMeta merged = McpMeta.merge(base, extra);
`

记录组件摘要Record Component Summary

组件Component类型Type说明Description
entriesMap<String, Object>
执行条目相关操作。
Performs the entries operation.

构造器摘要Constructor Summary

构造器Constructor说明Description
public McpMeta(Map<String, Object> entries)
初始化 `McpMeta` 实例。
Creates an McpMeta with the given entries.

方法摘要Method Summary

方法Method说明Description
public Map<String, Object> entries()
返回条目。
Returns the metadata entries as an unmodifiable map.
public boolean isEmpty()
判断是否 `isEmpty`。
Returns whether this meta contains no entries.
public static McpMeta merge(McpMeta... metas)
static
设置该参数。
Merges multiple `McpMeta` instances into one.
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
public String toString()
返回 `toString` 结果。
Returns the to string.

记录组件详情Record Component Detail

entries

Map<String, Object> entries

执行条目相关操作。

Performs the entries operation.

源码Source io/agentscope/core/tool/mcp/McpMeta.java:55–121

构造器详情Constructor Detail

McpMeta

public McpMeta(Map<String, Object> entries)

初始化 McpMeta 实例。

Creates an McpMeta with the given entries.

参数Parameters
名称Name类型Type说明Description
entriesMap<String, Object>条目(类型 `Map`)。the metadata entries (may be null or empty); the map is defensively copied
源码Source io/agentscope/core/tool/mcp/McpMeta.java:62–67

方法详情Method Detail

entries

public Map<String, Object> entries()

返回条目。

Returns the metadata entries as an unmodifiable map.

返回Returns Map<String, Object>
返回映射。the entries, never null (may be empty)
源码Source io/agentscope/core/tool/mcp/McpMeta.java:74–77

isEmpty

public boolean isEmpty()

判断是否 isEmpty。

Returns whether this meta contains no entries.

返回Returns boolean
返回布尔值,表示判断结果。true if empty, false otherwise
源码Source io/agentscope/core/tool/mcp/McpMeta.java:84–86

merge

public static McpMeta merge(McpMeta... metas)
static

设置该参数。

Merges multiple McpMeta instances into one.

参数Parameters
名称Name类型Type说明Description
metas varargsMcpMeta...metas(类型 `McpMeta...`)。the meta instances to merge (nulls are silently skipped)
返回Returns McpMeta
返回McpMeta。a new merged McpMeta, or an empty one if all inputs are null/empty
源码Source io/agentscope/core/tool/mcp/McpMeta.java:96–107

equals

public boolean equals(Object o)

设置该参数。

Performs the equals operation.

参数Parameters
名称Name类型Type说明Description
oObjecto(类型 `Object`)。The o.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/tool/mcp/McpMeta.java:109–115

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/tool/mcp/McpMeta.java:117–120
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.