* Registers a prompt with a config object and callback.
(
name: string,
config: {
title?: string;
description?: string;
argsSchema?: Args;
},
cb: PromptCallback<Args>
)
| 1137 | * Registers a prompt with a config object and callback. |
| 1138 | */ |
| 1139 | registerPrompt<Args extends PromptArgsRawShape>( |
| 1140 | name: string, |
| 1141 | config: { |
| 1142 | title?: string; |
| 1143 | description?: string; |
| 1144 | argsSchema?: Args; |
| 1145 | }, |
| 1146 | cb: PromptCallback<Args> |
| 1147 | ): RegisteredPrompt { |
| 1148 | if (this._registeredPrompts[name]) { |
| 1149 | throw new Error(`Prompt ${name} is already registered`); |
| 1150 | } |
| 1151 | |
| 1152 | const { title, description, argsSchema } = config; |
| 1153 | |
| 1154 | const registeredPrompt = this._createRegisteredPrompt( |
| 1155 | name, |
| 1156 | title, |
| 1157 | description, |
| 1158 | argsSchema, |
| 1159 | cb as PromptCallback<PromptArgsRawShape | undefined> |
| 1160 | ); |
| 1161 | |
| 1162 | this.setPromptRequestHandlers(); |
| 1163 | this.sendPromptListChanged(); |
| 1164 | |
| 1165 | return registeredPrompt; |
| 1166 | } |
| 1167 | |
| 1168 | /** |
| 1169 | * Checks if the server is connected to a transport. |
no test coverage detected