[WIP] Refactor everything server to be more modular and use recommended APIs.

* Adding dynamic resources

* Add server/index.js
  - import registerResources from resources/index.js
  - in createServer()
    - call registerResources, passing server

* Add resources/dynamic.ts
  - in addDynamicResources()
    - define formatGmtTimestamp to create a time stamp to include in the resource text or encoded blob
    - define parseIndex to ensure the index variable of the URI is a number

* Add resources/index.ts
  - import addDynamicResources
  - export registerResources function
  - in registerResources()
    - call addDynamicResources

* In package.json
  - update the start commands to launch each of the transports properly
This commit is contained in:
cliffhall
2025-12-04 19:01:18 -05:00
parent 5de886ca63
commit 8845118d61
4 changed files with 117 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { registerTools } from "../tools/index.js";
import { registerResources } from "../resources/index.js";
import { dirname, join } from "path";
import { readFileSync } from "fs";
import { fileURLToPath } from "url";
@@ -31,6 +32,9 @@ export const createServer = () => {
// Register the tools
registerTools(server);
// Register the resources
registerResources(server);
return {
server,
cleanup: () => {},