MCPcopy
hub / github.com/googleapis/mcp-toolbox / apiRouter

Function apiRouter

internal/server/api.go:35–51  ·  view source on GitHub ↗

apiRouter creates a router that represents the routes under /api

(s *Server)

Source from the content-addressed store, hash-verified

33
34// apiRouter creates a router that represents the routes under /api
35func apiRouter(s *Server) (chi.Router, error) {
36 r := chi.NewRouter()
37
38 r.Use(middleware.AllowContentType("application/json"))
39 r.Use(middleware.StripSlashes)
40 r.Use(render.SetContentType(render.ContentTypeJSON))
41
42 r.Get("/toolset", func(w http.ResponseWriter, r *http.Request) { toolsetHandler(s, w, r) })
43 r.Get("/toolset/{toolsetName}", func(w http.ResponseWriter, r *http.Request) { toolsetHandler(s, w, r) })
44
45 r.Route("/tool/{toolName}", func(r chi.Router) {
46 r.Get("/", func(w http.ResponseWriter, r *http.Request) { toolGetHandler(s, w, r) })
47 r.Post("/invoke", func(w http.ResponseWriter, r *http.Request) { toolInvokeHandler(s, w, r) })
48 })
49
50 return r, nil
51}
52
53// toolsetHandler handles the request for information about a Toolset.
54func toolsetHandler(s *Server, w http.ResponseWriter, r *http.Request) {

Callers 2

NewServerFunction · 0.85
setUpServerFunction · 0.85

Calls 4

toolsetHandlerFunction · 0.85
toolGetHandlerFunction · 0.85
toolInvokeHandlerFunction · 0.85
GetMethod · 0.65

Tested by 1

setUpServerFunction · 0.68