MCPcopy
hub / github.com/nanbingxyz/5ire / get

Method get

src/main/services/mcp-prompts-manager.ts:168–202  ·  view source on GitHub ↗

* Retrieves a prompt from an MCP server by its URI and processes its content. * * This method parses the provided URI to extract the connection ID and prompt name, * fetches the prompt from the corresponding MCP server, and converts any structured * content into a standardized format.

(options: MCPPromptsManager.GetOptions)

Source from the content-addressed store, hash-verified

166 * @param options - The options for retrieving a prompt, including the prompt URI and arguments
167 */
168 async get(options: MCPPromptsManager.GetOptions) {
169 const promptURI = this.#parsePromptURI(options.uri);
170
171 if (!promptURI) {
172 throw new Error("Invalid prompt uri format.");
173 }
174
175 const connection = this.#connectionsManager.getConnectedOrThrow(promptURI.connectionId);
176
177 if (!this.#loadedPrompts.find((prompt) => prompt.uri === options.uri)) {
178 throw new Error("Prompt not found.");
179 }
180
181 return connection.client.getPrompt({ name: promptURI.name, arguments: options.arguments }).then((result) => {
182 return {
183 description: result.description,
184 messages: result.messages.map((message) => {
185 let content = this.#contentConverter.convert(message.content, promptURI.connectionId);
186
187 // Some models or providers may throw errors when receiving messages with empty content
188 if (content.type === "text" && !content.text.trim()) {
189 content = {
190 type: "text",
191 text: "<tip>The previous message had empty content.</tip>",
192 };
193 }
194
195 return {
196 role: message.role,
197 content,
198 };
199 }),
200 };
201 });
202 }
203
204 async legacyList() {
205 const bundles = Array.from(this.state.collections.entries()).map(([id, collection]) => {

Callers 15

chatFunction · 0.80
usePromptStore.tsFile · 0.80
useChatStore.tsFile · 0.80
migrateSettingsFunction · 0.80
mergeProvidersFunction · 0.80
handleContextMenuCommandFunction · 0.80
saveToCloudFunction · 0.80
initLegacyDatabaseFunction · 0.80
cancelToolCallMethod · 0.80

Calls 4

#parsePromptURIMethod · 0.95
getConnectedOrThrowMethod · 0.80
getPromptMethod · 0.80
convertMethod · 0.45

Tested by

no test coverage detected