single-tenant servers set this context key to indicate that this particular mcp server process will only have 1 chat session in it this allows api optimizations where environment_id is not required and allows claude tasks inherit their parent's envs
(ctx context.Context, request mcp.CallToolRequest)
| 26 | // this allows api optimizations where environment_id is not required and allows claude tasks inherit their parent's envs |
| 27 | |
| 28 | func openRepository(ctx context.Context, request mcp.CallToolRequest) (*repository.Repository, error) { |
| 29 | // Check if we're in single-tenant mode |
| 30 | singleTenant, _ := ctx.Value(singleTenantKey{}).(bool) |
| 31 | |
| 32 | var source string |
| 33 | var err error |
| 34 | |
| 35 | if singleTenant { |
| 36 | // In single-tenant mode, try to get from stored value first |
| 37 | source = request.GetString("environment_source", "") |
| 38 | if source == "" { |
| 39 | source, err = getCurrentEnvironmentSource() |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | } |
| 44 | } else { |
| 45 | // In multi-tenant mode, environment_source is required |
| 46 | source, err = request.RequireString("environment_source") |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | repo, err := repository.Open(ctx, source) |
| 53 | if err != nil { |
| 54 | return nil, fmt.Errorf("unable to open repository: %w", err) |
| 55 | } |
| 56 | return repo, nil |
| 57 | } |
| 58 | |
| 59 | func openEnvironment(ctx context.Context, request mcp.CallToolRequest) (*repository.Repository, *environment.Environment, error) { |
| 60 | repo, err := openRepository(ctx, request) |
no test coverage detected