1
1
use crate :: config:: Config ;
2
2
use crate :: pinecone:: { PineconeClient , PineconeError } ;
3
+ use mcp_server:: router:: CapabilitiesBuilder ;
3
4
use mcp_spec:: content:: Content ;
4
5
use mcp_spec:: handler:: { PromptError , ResourceError , ToolError } ;
5
6
use mcp_spec:: prompt:: Prompt ;
6
7
use mcp_spec:: { protocol:: ServerCapabilities , resource:: Resource , tool:: Tool } ;
7
- use mcp_server:: router:: CapabilitiesBuilder ;
8
8
use serde_json:: Value ;
9
9
use std:: future:: Future ;
10
10
use std:: pin:: Pin ;
@@ -52,21 +52,24 @@ impl PineconeAssistantRouter {
52
52
client,
53
53
tools : vec ! [ Tool :: new(
54
54
TOOL_ASSISTANT_CONTEXT . to_string( ) ,
55
- "Retrieve context snippets from a Pinecone assistant knowledge base" . to_string( ) ,
55
+ "Retrieves relevant document snippets from your Pinecone Assistant knowledge base. \
56
+ Returns an array of text snippets from the most relevant documents. \
57
+ You can use the 'top_k' parameter to control result count (default: 15). \
58
+ Recommended top_k: a few (5-8) for simple/narrow queries, 10-20 for complex/broad topics.". to_string( ) ,
56
59
serde_json:: json!( {
57
60
"type" : "object" ,
58
61
"properties" : {
59
62
PARAM_ASSISTANT_NAME : {
60
63
"type" : "string" ,
61
- "description" : "Name of the Pinecone assistant"
64
+ "description" : "Name of an existing Pinecone assistant"
62
65
} ,
63
66
PARAM_QUERY : {
64
67
"type" : "string" ,
65
- "description" : "The query to use for generating context."
68
+ "description" : "The query to retrieve context for ."
66
69
} ,
67
70
PARAM_TOP_K : {
68
71
"type" : "integer" ,
69
- "description" : "Number of context snippets to return. Default is 15."
72
+ "description" : "The number of context snippets to retrieve. Defaults to 15."
70
73
}
71
74
} ,
72
75
"required" : [ PARAM_ASSISTANT_NAME , PARAM_QUERY ]
@@ -100,7 +103,11 @@ impl PineconeAssistantRouter {
100
103
. await ?;
101
104
102
105
tracing:: info!( "Successfully received response from Pinecone API" ) ;
103
- Ok ( vec ! [ Content :: text( response. snippets. to_string( ) ) ] )
106
+ Ok ( response
107
+ . snippets
108
+ . iter ( )
109
+ . map ( |snippet| Content :: text ( snippet. to_string ( ) ) )
110
+ . collect ( ) )
104
111
}
105
112
}
106
113
@@ -111,14 +118,9 @@ impl mcp_server::Router for PineconeAssistantRouter {
111
118
112
119
fn instructions ( & self ) -> String {
113
120
format ! (
114
- "This server provides tools to interact with Pinecone's Assistant API. \
115
- The {TOOL_ASSISTANT_CONTEXT} tool allows you to retrieve relevant context snippets from given knowledge base assistants. \
116
- Returned value structure: \
117
- An array of relevant document snippets, each containing: \
118
- - content: The text content of the snippet \
119
- - score: A relevance score (float) \
120
- - reference: Source information including document ID and location \
121
- You can tune the number of returned snippets by setting the `top_k` parameter."
121
+ "This server connects to an existing Pinecone Assistant,\
122
+ a RAG system for retrieving relevant document snippets. \
123
+ Use the {TOOL_ASSISTANT_CONTEXT} tool to access contextual information from its knowledge base"
122
124
)
123
125
}
124
126
0 commit comments