McpMeta
public record McpMeta(Map<String, Object> entries)
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 |
|---|---|---|
entries | Map<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.
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
entries | Map<String, Object> | 条目(类型 `Map`)。the metadata entries (may be null or empty); the map is defensively copied |
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.
Map<String, Object>io/agentscope/core/tool/mcp/McpMeta.java:74–77isEmpty
public boolean isEmpty()
判断是否 isEmpty。
Returns whether this meta contains no entries.
booleanio/agentscope/core/tool/mcp/McpMeta.java:84–86merge
public static McpMeta merge(McpMeta... metas)
设置该参数。
Merges multiple McpMeta instances into one.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
metas varargs | McpMeta... | metas(类型 `McpMeta...`)。the meta instances to merge (nulls are silently skipped) |
McpMetaio/agentscope/core/tool/mcp/McpMeta.java:96–107equals
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
o | Object | o(类型 `Object`)。The o. |
booleanio/agentscope/core/tool/mcp/McpMeta.java:109–115toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/tool/mcp/McpMeta.java:117–120