MCPcopy Index your code
hub / github.com/github/github-mcp-server / InjectDepsMiddleware

Function InjectDepsMiddleware

pkg/github/dependencies.go:33–39  ·  view source on GitHub ↗
(deps ToolDependencies)

Source from the content-addressed store, hash-verified

31var ErrDepsNotInContext = errors.New("ToolDependencies not found in context; use ContextWithDeps to inject")
32
33func InjectDepsMiddleware(deps ToolDependencies) mcp.Middleware {
34 return func(next mcp.MethodHandler) mcp.MethodHandler {
35 return func(ctx context.Context, method string, req mcp.Request) (result mcp.Result, err error) {
36 return next(ContextWithDeps(ctx, deps), method, req)
37 }
38 }
39}
40
41// ContextWithDeps returns a new context with the ToolDependencies stored in it.
42// This is used to inject dependencies at request time rather than at registration time,

Callers 1

NewMCPServerFunction · 0.85

Calls 1

ContextWithDepsFunction · 0.85

Tested by

no test coverage detected