(deps ToolDependencies)
| 31 | var ErrDepsNotInContext = errors.New("ToolDependencies not found in context; use ContextWithDeps to inject") |
| 32 | |
| 33 | func 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, |
no test coverage detected