mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-20 00:53:24 +02:00
* Adding static resources, move server instructions to
the new docs folder, and add code formatting
* Add docs folder
* Add docs/architecture.md which describes the architecture of the project thus far.
* Refactor moved instructions.md to docs/server-instructions.md
* Add resources/static.ts
- in addStaticResources()
- read the file entries from the docs folder
- register each file as a resource (no template), with a readResource function that reads the file and returns it in a contents block with the appropriate mime type and contents
- getMimeType helper function gets the mime type for a filename
- readSafe helper function reads the file synchronously as utf-8 or returns an error string
* Add resources/index.ts
- import addStaticResources
- export registerResources function
- in registerResources()
- call addStaticResources
* In package.json
- add prettier devDependency
- add prettier:check script
- add prettier:fix script
- in build script, copy docs folder to dist
* All other changes were prettier formatting
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Parse command line arguments first
|
|
const args = process.argv.slice(2);
|
|
const scriptName = args[0] || "stdio";
|
|
|
|
async function run() {
|
|
try {
|
|
// Dynamically import only the requested module to prevent all modules from initializing
|
|
switch (scriptName) {
|
|
case "stdio":
|
|
// Import and run the default server
|
|
await import("./transports/stdio.js");
|
|
break;
|
|
case "sse":
|
|
// Import and run the SSE server
|
|
await import("./transports/sse.js");
|
|
break;
|
|
case "streamableHttp":
|
|
// Import and run the streamable HTTP server
|
|
await import("./transports/streamableHttp.js");
|
|
break;
|
|
default:
|
|
console.error(`Unknown script: ${scriptName}`);
|
|
console.log("Available scripts:");
|
|
console.log("- stdio");
|
|
console.log("- sse");
|
|
console.log("- streamableHttp");
|
|
process.exit(1);
|
|
}
|
|
} catch (error) {
|
|
console.error("Error running script:", error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|