@@ -103,9 +103,7 @@ export class McpDocsServer {
103103 try {
104104 const results = await this . searchProvider . search ( query , { limit } ) ;
105105 return {
106- content : [
107- { type : 'text' as const , text : formatSearchResults ( results , this . config . baseUrl ) } ,
108- ] ,
106+ content : [ { type : 'text' as const , text : formatSearchResults ( results ) } ] ,
109107 } ;
110108 } catch ( error ) {
111109 console . error ( '[MCP] Search error:' , error ) ;
@@ -123,13 +121,15 @@ export class McpDocsServer {
123121 description :
124122 'Fetch the complete content of a documentation page. Use this when you need the full content of a specific page.' ,
125123 inputSchema : {
126- route : z
124+ url : z
127125 . string ( )
128- . min ( 1 )
129- . describe ( 'The page route path (e.g., "/docs/getting-started" or "/api/reference")' ) ,
126+ . url ( )
127+ . describe (
128+ 'The full URL of the page to fetch (e.g., "https://docs.example.com/docs/getting-started")'
129+ ) ,
130130 } ,
131131 } ,
132- async ( { route } ) => {
132+ async ( { url } ) => {
133133 await this . initialize ( ) ;
134134
135135 if ( ! this . searchProvider || ! this . searchProvider . isReady ( ) ) {
@@ -140,9 +140,9 @@ export class McpDocsServer {
140140 }
141141
142142 try {
143- const doc = await this . getDocument ( route ) ;
143+ const doc = await this . getDocument ( url ) ;
144144 return {
145- content : [ { type : 'text' as const , text : formatPageContent ( doc , this . config . baseUrl ) } ] ,
145+ content : [ { type : 'text' as const , text : formatPageContent ( doc ) } ] ,
146146 } ;
147147 } catch ( error ) {
148148 console . error ( '[MCP] Get page error:' , error ) ;
@@ -156,33 +156,15 @@ export class McpDocsServer {
156156 }
157157
158158 /**
159- * Get a document by route using the search provider
159+ * Get a document by URL using the search provider
160160 */
161- private async getDocument ( route : string ) : Promise < ProcessedDoc | null > {
161+ private async getDocument ( url : string ) : Promise < ProcessedDoc | null > {
162162 if ( ! this . searchProvider ) {
163163 return null ;
164164 }
165165
166- // Use the provider's getDocument if available
167166 if ( this . searchProvider . getDocument ) {
168- return this . searchProvider . getDocument ( route ) ;
169- }
170-
171- // For FlexSearchProvider, we can access docs directly
172- if ( this . searchProvider instanceof FlexSearchProvider ) {
173- const docs = this . searchProvider . getDocs ( ) ;
174- if ( ! docs ) return null ;
175-
176- // Try exact match first
177- if ( docs [ route ] ) {
178- return docs [ route ] ;
179- }
180-
181- // Try with/without leading slash
182- const normalizedRoute = route . startsWith ( '/' ) ? route : `/${ route } ` ;
183- const withoutSlash = route . startsWith ( '/' ) ? route . slice ( 1 ) : route ;
184-
185- return docs [ normalizedRoute ] ?? docs [ withoutSlash ] ?? null ;
167+ return this . searchProvider . getDocument ( url ) ;
186168 }
187169
188170 return null ;
0 commit comments