* Initializes this server with the given name and version information.
(
private _serverInfo: Implementation,
options?: ServerOptions
)
| 147 | * Initializes this server with the given name and version information. |
| 148 | */ |
| 149 | constructor( |
| 150 | private _serverInfo: Implementation, |
| 151 | options?: ServerOptions |
| 152 | ) { |
| 153 | super(options); |
| 154 | this._capabilities = options?.capabilities ?? {}; |
| 155 | this._instructions = options?.instructions; |
| 156 | this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator(); |
| 157 | |
| 158 | this.setRequestHandler(InitializeRequestSchema, request => this._oninitialize(request)); |
| 159 | this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.()); |
| 160 | |
| 161 | if (this._capabilities.logging) { |
| 162 | this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => { |
| 163 | const transportSessionId: string | undefined = |
| 164 | extra.sessionId || (extra.requestInfo?.headers['mcp-session-id'] as string) || undefined; |
| 165 | const { level } = request.params; |
| 166 | const parseResult = LoggingLevelSchema.safeParse(level); |
| 167 | if (parseResult.success) { |
| 168 | this._loggingLevels.set(transportSessionId, parseResult.data); |
| 169 | } |
| 170 | return {}; |
| 171 | }); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Access experimental features. |
nothing calls this directly
no test coverage detected