Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AI/NetApp-KnowledgeBase-MCP-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ async function startServer() {
logger.info('Received knowledge bases', JSON.stringify(knowledgeBases, null, 2) , 'defining tools');
knowledgeBases.forEach(knowledgeBase => {
const {id: knowledgeBaseId, name, description} = knowledgeBase;
server.tool(`search_KB_${name}`, `Search knowledge base with description ${description}`, {
const toolName = `search_KB_${name}`.slice(0, 64).replaceAll(/[^a-zA-Z0-9_-]/g,'_'); // MCP tool names should be less than 64 characters
server.tool(toolName, `Search knowledge base with description ${description}`, {
question: z.string({description: 'Question to search the answer to in the knowledge base'})
}, async ({question}) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ export async function getAiEngines(){
return deployments;
}

export async function getKnowledgeBases( deploymentId:string){
export async function getKnowledgeBases( deploymentId:string, token?:string){
const {knowledgeBases = [], nextToken} = await got.get(`${WLMAI_URL}/accounts/${process.env.ACCOUNT_ID}/wlmai/v2/deployments/${deploymentId}/knowledge-bases`, {
headers:{
authorization: await getToken()
}
},
searchParams: token ? {token} : {}
}).json<{knowledgeBases:KnowledgeBase[], nextToken?:string}>()
return {knowledgeBases, nextToken};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ async function* getKnowledgeBasesGenerator(aiEngineId:string){
let { knowledgeBases, nextToken } = await getKnowledgeBases(aiEngineId);
yield knowledgeBases;
while (nextToken) {
({ knowledgeBases, nextToken } = await getKnowledgeBases(aiEngineId));
({ knowledgeBases, nextToken } = await getKnowledgeBases(aiEngineId, nextToken));
yield knowledgeBases;
}

}

async function listAllKnowledgeBases(aiEngineId:string){
Expand Down