@xyd-js/mcp-server 0.0.0-build-57e447b-20251021171927 → 0.0.0-build-66ba948-20251024195101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/mcp-server",
3
- "version": "0.0.0-build-57e447b-20251021171927",
3
+ "version": "0.0.0-build-66ba948-20251024195101",
4
4
  "type": "module",
5
5
  "description": "MCP server for xyd",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/sdk": "^1.18.1",
23
23
  "express": "^5.1.0",
24
- "@xyd-js/mcp": "0.0.0-build-57e447b-20251021171927"
24
+ "@xyd-js/mcp": "0.0.0-build-66ba948-20251024195101"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/express": "^4.17.21",
package/src/index.ts CHANGED
@@ -2,7 +2,15 @@ import express from "express";
2
2
 
3
3
  import { MCPServer } from "./mcp";
4
4
 
5
- const mcp = new MCPServer();
5
+ // Support both uniform sources and llms.txt sources
6
+ const uniformSources = process.argv[2];
7
+ const llmsSources = process.argv[3];
8
+
9
+ const mcp = new MCPServer({
10
+ uniformSources,
11
+ llmsSources,
12
+ openAIApiKey: process.env.OPENAI_API_KEY || "", // TODO: configurable
13
+ });
6
14
  const app = express();
7
15
 
8
16
  app.use(express.json());
package/src/mcp.ts CHANGED
@@ -6,7 +6,7 @@ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
6
6
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
 
9
- import { mcpUniformResources, mcpUniformTools } from "@xyd-js/mcp";
9
+ import { mcpUniformResources, mcpUniformTools, mcpLLMsResources, mcpLLMsTools } from "@xyd-js/mcp";
10
10
 
11
11
  // Extend Express Request type to include pendingToken
12
12
  declare global {
@@ -17,6 +17,12 @@ declare global {
17
17
  }
18
18
  }
19
19
 
20
+ interface MCPServerOptions {
21
+ uniformSources: string | string[]
22
+ llmsSources: string | string[]
23
+ openAIApiKey: string // TODO: support other LLMS embeddings
24
+ }
25
+
20
26
  export class MCPServer {
21
27
  private transports: { [sessionId: string]: StreamableHTTPServerTransport } =
22
28
  {};
@@ -25,8 +31,11 @@ export class MCPServer {
25
31
  private sessionTokens: { [sessionId: string]: string } = {};
26
32
 
27
33
  private uniformSources: string[] = []
34
+ private llmsSources: string[] = []
35
+
36
+ constructor(protected options: MCPServerOptions) {
37
+ const { uniformSources, llmsSources } = options;
28
38
 
29
- constructor(uniformSources: string | string[] = process.argv[2]) {
30
39
  this.connect = this.connect.bind(this);
31
40
  this.handleConnectionRequest = this.handleConnectionRequest.bind(this);
32
41
  this.handleSessionRequest = this.handleSessionRequest.bind(this);
@@ -36,6 +45,13 @@ export class MCPServer {
36
45
  } else if (uniformSources && Array.isArray(uniformSources)) {
37
46
  this.uniformSources.push(...uniformSources);
38
47
  }
48
+
49
+ // Handle llms.txt sources
50
+ if (llmsSources && typeof llmsSources === "string") {
51
+ this.llmsSources.push(llmsSources);
52
+ } else if (llmsSources && Array.isArray(llmsSources)) {
53
+ this.llmsSources.push(...llmsSources);
54
+ }
39
55
  }
40
56
 
41
57
  public async handleConnectionRequest(
@@ -134,6 +150,12 @@ export class MCPServer {
134
150
 
135
151
  await mcpUniformTools(server, source || "", token || "");
136
152
 
153
+ // Add llms.txt resources and tools
154
+ if (this.llmsSources.length > 0) {
155
+ // await mcpLLMsResources(server, this.llmsSources);
156
+ await mcpLLMsTools(server, this.llmsSources, this.options.openAIApiKey);
157
+ }
158
+
137
159
  // Add simple token tool
138
160
  this.addSimpleTokenTool(server);
139
161
 
@@ -220,4 +242,5 @@ export class MCPServer {
220
242
  this.transports = {};
221
243
  this.sessionTokens = {};
222
244
  }
245
+
223
246
  }