mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 16:43:24 +02:00
[WIP] Refactor everything server to be more modular and use recommended APIs.
* 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
This commit is contained in:
@@ -10,45 +10,48 @@ const instructions = readInstructions();
|
||||
|
||||
// Create the MCP resource server
|
||||
export const createServer = () => {
|
||||
const server = new McpServer(
|
||||
{
|
||||
name: "mcp-servers/everything",
|
||||
title: "Everything Reference Server",
|
||||
version: "2.0.0",
|
||||
const server = new McpServer(
|
||||
{
|
||||
name: "mcp-servers/everything",
|
||||
title: "Everything Reference Server",
|
||||
version: "2.0.0",
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
tools: {},
|
||||
logging: {},
|
||||
prompts: {},
|
||||
resources: {
|
||||
subscribe: true,
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
tools: {},
|
||||
logging: {},
|
||||
prompts: {},
|
||||
resources: {
|
||||
subscribe: true,
|
||||
}
|
||||
},
|
||||
instructions,
|
||||
},
|
||||
);
|
||||
},
|
||||
instructions,
|
||||
}
|
||||
);
|
||||
|
||||
// Register the tools
|
||||
registerTools(server);
|
||||
// Register the tools
|
||||
registerTools(server);
|
||||
|
||||
// Register the resources
|
||||
registerResources(server);
|
||||
// Register the resources
|
||||
registerResources(server);
|
||||
|
||||
return {
|
||||
server,
|
||||
cleanup: () => {},
|
||||
startNotificationIntervals: (sessionId?: string) => {}
|
||||
};
|
||||
return {
|
||||
server,
|
||||
cleanup: () => {},
|
||||
startNotificationIntervals: (sessionId?: string) => {},
|
||||
};
|
||||
};
|
||||
|
||||
function readInstructions(): string {
|
||||
let instructions;
|
||||
let instructions;
|
||||
|
||||
try {
|
||||
instructions = readFileSync(join(__dirname, "../instructions.md"), "utf-8");
|
||||
} catch (e) {
|
||||
instructions = "Server instructions not loaded: " + e;
|
||||
}
|
||||
return instructions;
|
||||
try {
|
||||
instructions = readFileSync(
|
||||
join(__dirname, "..", "docs", "server-instructions.md"),
|
||||
"utf-8"
|
||||
);
|
||||
} catch (e) {
|
||||
instructions = "Server instructions not loaded: " + e;
|
||||
}
|
||||
return instructions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user