AS AgentScopeAPI 手册 / API Reference

McpServerConfig

@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonIgnoreProperties(ignoreUnknown = true) public class McpServerConfig
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:40–216

MCP 服务端配置,保存相关配置项。位于 io.agentscope.harness.agent.tools 包。核心成员包括 getConnectionFailureHandler、setConnectionFailureHandler、isDefaultToolsEnabled、setDefaultToolsEnabled、getDisableTools、setDisableTools。

One MCP server entry under mcpServers.<name> in tools.json.

Mirrors the standard MCP client configuration shape so that workspaces can be moved between AgentScope and other MCP-aware tools with minimal edits. Field semantics map directly onto io.agentscope.core.tool.mcp.McpClientBuilder.

transport is the discriminator:

  • stdio — uses #command + #args + #env.

  • sse — uses #url + #headers + #queryParams.

  • http — streamable HTTP, same fields as sse.

方法摘要Method Summary

方法Method说明Description
public java.util.function.Consumer<McpConnectionException> getConnectionFailureHandler()
获取连接失败处理器。
Returns the connection failure handler.
public void setConnectionFailureHandler(java.util.function.Consumer<McpConnectionException> handler)
设置连接失败处理器。
Sets the connection failure handler.
public boolean isDefaultToolsEnabled()
判断是否默认工具已启用。
Returns whether the default tools enabled.
public void setDefaultToolsEnabled(boolean value)
设置默认工具已启用。
Sets the default tools enabled.
public List<String> getDisableTools()
获取禁用工具。
Returns the disable tools.
public void setDisableTools(List<String> value)
设置禁用工具。
Sets the disable tools.
public boolean isPrefixToolNames()
判断是否 `isPrefixToolNames`。
Returns whether the prefix tool names.
public void setPrefixToolNames(boolean value)
设置 `setPrefixToolNames`。
Sets the prefix tool names.
public boolean isRequired()
判断是否必填。
Returns whether the required.
public void setRequired(boolean value)
设置必填。
Sets the required.
public String getTransport()
获取传输层。
Returns the transport.
public void setTransport(String transport)
设置传输层。
Sets the transport.
public String getCommand()
获取命令。
Returns the command.
public void setCommand(String command)
设置命令。
Sets the command.
public List<String> getArgs()
获取参数。
Returns the args.
public void setArgs(List<String> args)
设置参数。
Sets the args.
public Map<String, String> getEnv()
获取 `getEnv`。
Returns the env.
public void setEnv(Map<String, String> env)
设置 `setEnv`。
Sets the env.
public String getUrl()
获取URL。
Returns the url.
public void setUrl(String url)
设置URL。
Sets the url.
public Map<String, String> getHeaders()
获取请求头。
Returns the headers.
public void setHeaders(Map<String, String> headers)
设置请求头。
Sets the headers.
public Map<String, String> getQueryParams()
获取查询参数。
Returns the query params.
public void setQueryParams(Map<String, String> queryParams)
设置查询参数。
Sets the query params.
public List<String> getEnableTools()
获取启用工具。
Returns the enable tools.
public void setEnableTools(List<String> enableTools)
设置启用工具。
Sets the enable tools.
public Duration getTimeout()
获取超时。
Returns the timeout.
public void setTimeout(Duration timeout)
设置超时。
Sets the timeout.
public Duration getInitializationTimeout()
获取 `getInitializationTimeout`。
Returns the initialization timeout.
public void setInitializationTimeout(Duration initializationTimeout)
设置 `setInitializationTimeout`。
Sets the initialization timeout.

方法详情Method Detail

getConnectionFailureHandler

public java.util.function.Consumer<McpConnectionException> getConnectionFailureHandler()

获取连接失败处理器。

Returns the connection failure handler.

返回Returns java.util.function.Consumer<McpConnectionException>
返回java.util.函数.消费者。Returns java util function consumer.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:95–98

setConnectionFailureHandler

public void setConnectionFailureHandler(java.util.function.Consumer<McpConnectionException> handler)

设置连接失败处理器。

Sets the connection failure handler.

参数Parameters
名称Name类型Type说明Description
handlerjava.util.function.Consumer<McpConnectionException>处理器(类型 `java.util.function.Consumer`)。The handler.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:100–103

isDefaultToolsEnabled

public boolean isDefaultToolsEnabled()

判断是否默认工具已启用。

Returns whether the default tools enabled.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:105–107

setDefaultToolsEnabled

public void setDefaultToolsEnabled(boolean value)

设置默认工具已启用。

Sets the default tools enabled.

参数Parameters
名称Name类型Type说明Description
valueboolean值(类型 `boolean`)。The value.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:109–111

getDisableTools

public List<String> getDisableTools()

获取禁用工具。

Returns the disable tools.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:113–115

setDisableTools

public void setDisableTools(List<String> value)

设置禁用工具。

Sets the disable tools.

参数Parameters
名称Name类型Type说明Description
valueList<String>值(类型 `List`)。The value.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:117–119

isPrefixToolNames

public boolean isPrefixToolNames()

判断是否 isPrefixToolNames。

Returns whether the prefix tool names.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:121–123

setPrefixToolNames

public void setPrefixToolNames(boolean value)

设置 setPrefixToolNames。

Sets the prefix tool names.

参数Parameters
名称Name类型Type说明Description
valueboolean值(类型 `boolean`)。The value.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:125–127

isRequired

public boolean isRequired()

判断是否必填。

Returns whether the required.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:129–131

setRequired

public void setRequired(boolean value)

设置必填。

Sets the required.

参数Parameters
名称Name类型Type说明Description
valueboolean值(类型 `boolean`)。The value.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:133–135

getTransport

public String getTransport()

获取传输层。

Returns the transport.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:137–139

setTransport

public void setTransport(String transport)

设置传输层。

Sets the transport.

参数Parameters
名称Name类型Type说明Description
transportString传输层(类型 `String`)。The transport.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:141–143

getCommand

public String getCommand()

获取命令。

Returns the command.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:145–147

setCommand

public void setCommand(String command)

设置命令。

Sets the command.

参数Parameters
名称Name类型Type说明Description
commandString命令(类型 `String`)。The command.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:149–151

getArgs

public List<String> getArgs()

获取参数。

Returns the args.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:153–155

setArgs

public void setArgs(List<String> args)

设置参数。

Sets the args.

参数Parameters
名称Name类型Type说明Description
argsList<String>参数(类型 `List`)。The args.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:157–159

getEnv

public Map<String, String> getEnv()

获取 getEnv。

Returns the env.

返回Returns Map<String, String>
返回映射。Returns map.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:161–163

setEnv

public void setEnv(Map<String, String> env)

设置 setEnv。

Sets the env.

参数Parameters
名称Name类型Type说明Description
envMap<String, String>env(类型 `Map`)。The env.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:165–167

getUrl

public String getUrl()

获取URL。

Returns the url.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:169–171

setUrl

public void setUrl(String url)

设置URL。

Sets the url.

参数Parameters
名称Name类型Type说明Description
urlString服务地址(类型 `String`)。The url.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:173–175

getHeaders

public Map<String, String> getHeaders()

获取请求头。

Returns the headers.

返回Returns Map<String, String>
返回映射。Returns map.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:177–179

setHeaders

public void setHeaders(Map<String, String> headers)

设置请求头。

Sets the headers.

参数Parameters
名称Name类型Type说明Description
headersMap<String, String>请求头(类型 `Map`)。The headers.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:181–183

getQueryParams

public Map<String, String> getQueryParams()

获取查询参数。

Returns the query params.

返回Returns Map<String, String>
返回映射。Returns map.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:185–187

setQueryParams

public void setQueryParams(Map<String, String> queryParams)

设置查询参数。

Sets the query params.

参数Parameters
名称Name类型Type说明Description
queryParamsMap<String, String>查询参数(类型 `Map`)。The query params.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:189–191

getEnableTools

public List<String> getEnableTools()

获取启用工具。

Returns the enable tools.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:193–195

setEnableTools

public void setEnableTools(List<String> enableTools)

设置启用工具。

Sets the enable tools.

参数Parameters
名称Name类型Type说明Description
enableToolsList<String>启用工具(类型 `List`)。The enable tools.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:197–199

getTimeout

public Duration getTimeout()

获取超时。

Returns the timeout.

返回Returns Duration
返回时长。Returns duration.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:201–203

setTimeout

public void setTimeout(Duration timeout)

设置超时。

Sets the timeout.

参数Parameters
名称Name类型Type说明Description
timeoutDuration超时时间(类型 `Duration`)。The timeout.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:205–207

getInitializationTimeout

public Duration getInitializationTimeout()

获取 getInitializationTimeout。

Returns the initialization timeout.

返回Returns Duration
返回时长。Returns duration.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:209–211

setInitializationTimeout

public void setInitializationTimeout(Duration initializationTimeout)

设置 setInitializationTimeout。

Sets the initialization timeout.

参数Parameters
名称Name类型Type说明Description
initializationTimeoutDurationinitialization 超时(类型 `Duration`)。The initialization timeout.
源码Source io/agentscope/harness/agent/tools/McpServerConfig.java:213–215
基于官方固定版本源码静态生成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.