MCPcopy Create free account
hub / github.com/astercloud/aster / New

Function New

pkg/mcpserver/server.go:37–58  ·  view source on GitHub ↗

New 创建一个 MCP Server 实例

(cfg *Config)

Source from the content-addressed store, hash-verified

35
36// New 创建一个 MCP Server 实例
37func New(cfg *Config) (*Server, error) {
38 if cfg == nil {
39 return nil, errors.New("mcpserver.Config cannot be nil")
40 }
41 if cfg.Registry == nil {
42 return nil, errors.New("registry is required")
43 }
44
45 executor := cfg.Executor
46 if executor == nil {
47 executor = tools.NewExecutor(tools.ExecutorConfig{
48 MaxConcurrency: 3,
49 DefaultTimeout: 60 * time.Second,
50 })
51 }
52
53 return &Server{
54 registry: cfg.Registry,
55 executor: executor,
56 contextFactory: cfg.ContextFactory,
57 }, nil
58}
59
60// Handler 返回一个 http.Handler, 处理 MCP JSON-RPC 请求。
61//

Callers 2

runMCPServeFunction · 0.92
mainFunction · 0.92

Calls 1

NewExecutorFunction · 0.92

Tested by

no test coverage detected