File tree Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " ansible-database-mcp " : patch
3
+ ---
4
+
5
+ lazy load wrap-up content in prompt handler
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { z } from 'zod';
5
5
import { Paths } from '../config/paths.js' ;
6
6
7
7
let guideContent : string | undefined ;
8
- let contextContent : string | undefined ;
9
8
10
9
const definition : PromptDefinition = {
11
10
name : 'ask' ,
@@ -32,26 +31,13 @@ const getGuideContent = async () => {
32
31
}
33
32
} ;
34
33
35
-
36
- const getContextContent = async ( ) => {
37
-
38
- if ( contextContent ) {
39
- return contextContent ;
40
- }
41
-
42
- const contextPath = Paths . getContextPath ( ) ;
43
- contextContent = readFileSync ( contextPath , 'utf-8' ) ;
44
- return contextContent ;
45
- } ;
46
-
47
- const handler : ( question : string , useContext ?: boolean ) => Promise < GetPromptResult > = async ( question : string , useContext ?: boolean ) => {
34
+ const handler : ( question : string , useContext ?: string ) => Promise < GetPromptResult > = async ( question : string , useContext ?: string ) => {
48
35
const guideContent = await getGuideContent ( ) ;
49
36
50
37
let response = `${ guideContent } \n\nQuestion: ${ question } ` ;
51
38
52
39
if ( useContext ) {
53
- const contextContent = await getContextContent ( ) ;
54
- response += `\n\nContext: ${ contextContent } ` ;
40
+ response += `\n\nContext: ${ useContext } ` ;
55
41
}
56
42
57
43
return {
Original file line number Diff line number Diff line change @@ -2,14 +2,19 @@ import { Paths } from "@/config/paths";
2
2
import { PromptDefinition } from "@/types/modelcontextprotocol" ;
3
3
import { GetPromptResult } from "@modelcontextprotocol/sdk/types" ;
4
4
5
- const wrapUpContent = Paths . getAssetsTextFile ( 'wrap-up.md' ) ;
6
5
7
6
const definition : PromptDefinition = {
8
7
name : 'wrap-up' ,
9
8
description : 'Wrap up the conversation and generate a schema document'
10
9
} ;
11
10
11
+ let wrapUpContent : string ;
12
+
12
13
const handler : ( ) => Promise < GetPromptResult > = async ( ) => {
14
+ if ( ! wrapUpContent ) {
15
+ wrapUpContent = Paths . getAssetsTextFile ( 'wrap-up.md' ) ;
16
+ }
17
+
13
18
return {
14
19
messages : [
15
20
{
You can’t perform that action at this time.
0 commit comments