1- import { dirname , join } from 'node:path' ;
2- import { fileURLToPath } from 'node:url' ;
31import { McpServer } from 'tmcp' ;
42import * as v from 'valibot' ;
53
64import {
7- DefinitionItem ,
8- get_all_identifiers ,
9- get_definition_by_identifier ,
10- load_definitions ,
11- suggest_similar_identifiers ,
12- } from '../definition-loader.js' ;
13-
14- // Get the definitions directory path
15- const __filename = fileURLToPath ( import . meta. url ) ;
16- const __dirname = dirname ( __filename ) ;
17- const definitionsDir = join ( __dirname , '../../definitions' ) ;
5+ DefinitionItem ,
6+ get_all_identifiers ,
7+ get_definition_by_identifier ,
8+ load_definitions ,
9+ suggest_similar_identifiers ,
10+ } from '../db-definition-loader.js' ;
1811
1912// Load all definitions
2013let definitions : DefinitionItem [ ] = [ ] ;
@@ -155,11 +148,8 @@ function create_definition_error(
155148 identifier : string ,
156149 definitions : DefinitionItem [ ] ,
157150) : Error {
158- const suggestions = suggest_similar_identifiers (
159- definitions ,
160- identifier ,
161- ) ;
162- const all_identifiers = get_all_identifiers ( definitions ) ;
151+ const suggestions = suggest_similar_identifiers ( identifier ) ;
152+ const all_identifiers = get_all_identifiers ( ) ;
163153
164154 let error_message = `Definition for '${ identifier } ' not found.` ;
165155
@@ -211,10 +201,7 @@ async function definition_handler(args: any) {
211201 ) ;
212202
213203 // Find the definition
214- const definition = get_definition_by_identifier (
215- definitions ,
216- identifier ,
217- ) ;
204+ const definition = get_definition_by_identifier ( identifier ) ;
218205
219206 if ( ! definition ) {
220207 throw create_definition_error ( identifier , definitions ) ;
@@ -294,7 +281,7 @@ export function register_definition_tools(
294281 server : McpServer < any > ,
295282) : void {
296283 // Load all definitions
297- definitions = load_definitions ( definitionsDir ) ;
284+ definitions = load_definitions ( ) ;
298285
299286 if ( definitions . length === 0 ) {
300287 console . warn (
@@ -303,7 +290,7 @@ export function register_definition_tools(
303290 } else {
304291 console . log (
305292 `Loaded ${ definitions . length } definitions:` ,
306- get_all_identifiers ( definitions ) ,
293+ get_all_identifiers ( ) ,
307294 ) ;
308295 }
309296
0 commit comments