AddTool registers a tool with the server.
(name, description string, schema InputSchema, handler ToolHandler)
| 108 | |
| 109 | // AddTool registers a tool with the server. |
| 110 | func (s *Server) AddTool(name, description string, schema InputSchema, handler ToolHandler) { |
| 111 | s.mu.Lock() |
| 112 | defer s.mu.Unlock() |
| 113 | |
| 114 | s.tools = append(s.tools, Tool{ |
| 115 | Name: name, |
| 116 | Description: description, |
| 117 | InputSchema: schema, |
| 118 | }) |
| 119 | s.handlers[name] = handler |
| 120 | } |
| 121 | |
| 122 | // ServeHTTP handles MCP requests over Streamable HTTP. |
| 123 | func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
no outgoing calls