sad-mcp 0.1.2 → 0.1.3
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/dist/index.js +4 -10
- package/dist/resources.js +17 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,27 +4,21 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { registerResourceHandlers } from "./resources.js";
|
|
5
5
|
import { registerToolHandlers } from "./tools.js";
|
|
6
6
|
import { trackServerStart } from "./tracking.js";
|
|
7
|
-
import { getAuthenticatedClient } from "./auth.js";
|
|
8
7
|
async function main() {
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
await getAuthenticatedClient();
|
|
13
|
-
console.error("SAD MCP: Authentication ready.");
|
|
14
|
-
const server = new Server({ name: "sad-mcp", version: "0.1.1" }, {
|
|
8
|
+
// Connect to Claude Desktop IMMEDIATELY — no blocking auth here
|
|
9
|
+
// Auth happens lazily on first Drive API call
|
|
10
|
+
const server = new Server({ name: "sad-mcp", version: "0.1.3" }, {
|
|
15
11
|
capabilities: {
|
|
16
12
|
resources: {},
|
|
17
13
|
tools: {},
|
|
18
14
|
},
|
|
19
15
|
});
|
|
20
|
-
// Register all handlers
|
|
21
16
|
registerResourceHandlers(server);
|
|
22
17
|
registerToolHandlers(server);
|
|
23
|
-
// Track server startup
|
|
24
18
|
trackServerStart();
|
|
25
19
|
const transport = new StdioServerTransport();
|
|
26
20
|
await server.connect(transport);
|
|
27
|
-
console.error("SAD MCP server started.
|
|
21
|
+
console.error("SAD MCP server started.");
|
|
28
22
|
}
|
|
29
23
|
main().catch((err) => {
|
|
30
24
|
console.error("SAD MCP failed to start:", err);
|
package/dist/resources.js
CHANGED
|
@@ -7,29 +7,30 @@ function fileToUri(file) {
|
|
|
7
7
|
const encodedName = encodeURIComponent(file.name);
|
|
8
8
|
return `sad://${category}/${encodedName}`;
|
|
9
9
|
}
|
|
10
|
-
function mimeForExtraction(file) {
|
|
11
|
-
// All resources are served as extracted text
|
|
12
|
-
return "text/plain";
|
|
13
|
-
}
|
|
14
10
|
export function registerResourceHandlers(server) {
|
|
15
|
-
// List all available resources
|
|
11
|
+
// List all available resources — returns empty list on error (e.g. during first auth)
|
|
16
12
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
try {
|
|
14
|
+
const files = await listAllFiles();
|
|
15
|
+
const extractableFiles = files.filter(isExtractable);
|
|
16
|
+
return {
|
|
17
|
+
resources: extractableFiles.map((file) => ({
|
|
18
|
+
uri: fileToUri(file),
|
|
19
|
+
name: file.name,
|
|
20
|
+
description: `[${categorizeFile(file)}] ${file.path}`,
|
|
21
|
+
mimeType: "text/plain",
|
|
22
|
+
})),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
console.error("SAD MCP: Error listing resources:", err);
|
|
27
|
+
return { resources: [] };
|
|
28
|
+
}
|
|
27
29
|
});
|
|
28
30
|
// Read a specific resource
|
|
29
31
|
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
30
32
|
const uri = request.params.uri;
|
|
31
33
|
const files = await listAllFiles();
|
|
32
|
-
// Find the file matching this URI
|
|
33
34
|
const file = files.find((f) => fileToUri(f) === uri);
|
|
34
35
|
if (!file) {
|
|
35
36
|
throw new Error(`Resource not found: ${uri}`);
|