MCPcopy Index your code
hub / github.com/coder/coder / NewServer

Function NewServer

coderd/aibridgedserver/aibridgedserver.go:92–125  ·  view source on GitHub ↗
(lifecycleCtx context.Context, store store, logger slog.Logger, accessURL string,
	bridgeCfg codersdk.AIBridgeConfig, externalAuthConfigs []*externalauth.Config, experiments codersdk.Experiments,
	aiSeatTracker aiseats.SeatTracker,
)

Source from the content-addressed store, hash-verified

90}
91
92func NewServer(lifecycleCtx context.Context, store store, logger slog.Logger, accessURL string,
93 bridgeCfg codersdk.AIBridgeConfig, externalAuthConfigs []*externalauth.Config, experiments codersdk.Experiments,
94 aiSeatTracker aiseats.SeatTracker,
95) (*Server, error) {
96 eac := make(map[string]*externalauth.Config, len(externalAuthConfigs))
97
98 for _, cfg := range externalAuthConfigs {
99 // Only External Auth configs which are configured with an MCP URL are relevant to aibridged.
100 if cfg.MCPURL == "" {
101 continue
102 }
103 eac[cfg.ID] = cfg
104 }
105
106 srv := &Server{
107 lifecycleCtx: lifecycleCtx,
108 store: store,
109 logger: logger,
110 externalAuthConfigs: eac,
111 structuredLogging: bridgeCfg.StructuredLogging.Value(),
112 aiSeatTracker: aiSeatTracker,
113 }
114
115 if bridgeCfg.InjectCoderMCPTools {
116 logger.Warn(lifecycleCtx, "inject MCP tools option is deprecated and will be removed in a future release")
117 coderMCPConfig, err := getCoderMCPServerConfig(experiments, accessURL)
118 if err != nil {
119 logger.Warn(lifecycleCtx, "failed to retrieve coder MCP server config, Coder MCP will not be available", slog.Error(err))
120 }
121 srv.coderMCPConfig = coderMCPConfig
122 }
123
124 return srv, nil
125}
126
127func (s *Server) RecordInterception(ctx context.Context, in *proto.RecordInterceptionRequest) (*proto.RecordInterceptionResponse, error) {
128 //nolint:gocritic // AIBridged has specific authz rules.

Callers 8

TestAuthorizationFunction · 0.92
TestGetMCPServerConfigsFunction · 0.92
testRecordMethodFunction · 0.92
TestStructuredLoggingFunction · 0.92

Calls 3

getCoderMCPServerConfigFunction · 0.85
ValueMethod · 0.45
ErrorMethod · 0.45

Tested by 7

TestAuthorizationFunction · 0.74
TestGetMCPServerConfigsFunction · 0.74
testRecordMethodFunction · 0.74
TestStructuredLoggingFunction · 0.74