matome-mcp-server 0.0.1 → 0.0.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/README.md +2 -0
- package/dist/index.js +83 -3
- package/package.json +11 -14
- package/dist/tools/ExampleTool.js +0 -16
- package/dist/tools/MatomeTool.js +0 -51
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
server.
|
|
2
|
+
import "dotenv/config";
|
|
3
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
const MATOME_API_BASE = "https://matome.ebi-generator.com/api/mcp";
|
|
7
|
+
const server = new Server({
|
|
8
|
+
name: "matome",
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
}, {
|
|
11
|
+
capabilities: {
|
|
12
|
+
tools: {},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
async function makeMatomeRequest() {
|
|
16
|
+
try {
|
|
17
|
+
const Url = `${MATOME_API_BASE}`;
|
|
18
|
+
const UID = process.env.USER_ID;
|
|
19
|
+
const response = await fetch(Url, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: {
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({ uid: UID }),
|
|
25
|
+
});
|
|
26
|
+
if (response.status !== 200) {
|
|
27
|
+
return { content: [{ type: "text", text: "matome fetch Error!!" }] };
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const result = await response.json();
|
|
31
|
+
const resultlist = { content: [] };
|
|
32
|
+
result.list.forEach((item) => {
|
|
33
|
+
resultlist.content.push({ type: "text", text: item.url });
|
|
34
|
+
});
|
|
35
|
+
return resultlist;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: "matome url list is none",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
50
|
+
return {
|
|
51
|
+
tools: [
|
|
52
|
+
{
|
|
53
|
+
name: "get_matome",
|
|
54
|
+
description: "Get bookmark url for matome",
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: "object",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
63
|
+
try {
|
|
64
|
+
if (request.params.name === "get_matome") {
|
|
65
|
+
const ar_Data = await makeMatomeRequest();
|
|
66
|
+
return ar_Data;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: "Tool not found",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new Error("Tool not found");
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const transport = new StdioServerTransport();
|
|
84
|
+
await server.connect(transport);
|
package/package.json
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matome-mcp-server",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "matome
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "matome",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "matome",
|
|
5
7
|
"type": "module",
|
|
6
8
|
"bin": {
|
|
7
9
|
"matome-mcp-server": "./dist/index.js"
|
|
8
10
|
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc && chmod 755 dist/index.js"
|
|
13
|
+
},
|
|
9
14
|
"files": [
|
|
10
15
|
"dist"
|
|
11
16
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsc && mcp-build",
|
|
14
|
-
"watch": "tsc --watch",
|
|
15
|
-
"start": "node dist/index.js"
|
|
16
|
-
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"@modelcontextprotocol/sdk": "^1.11.3",
|
|
19
|
+
"dotenv": "^16.5.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "^
|
|
23
|
-
"typescript": "^5.
|
|
24
|
-
},
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=18.19.0"
|
|
22
|
+
"@types/node": "^22.15.18",
|
|
23
|
+
"typescript": "^5.8.3"
|
|
27
24
|
}
|
|
28
25
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MCPTool } from "mcp-framework";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
class ExampleTool extends MCPTool {
|
|
4
|
-
name = "example_tool";
|
|
5
|
-
description = "An example tool that processes messages";
|
|
6
|
-
schema = {
|
|
7
|
-
message: {
|
|
8
|
-
type: z.string(),
|
|
9
|
-
description: "Message to process",
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
async execute(input) {
|
|
13
|
-
return `Processed: ${input.message}`;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default ExampleTool;
|
package/dist/tools/MatomeTool.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { MCPTool } from "mcp-framework";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import "dotenv/config";
|
|
4
|
-
class MatomeTool extends MCPTool {
|
|
5
|
-
name = "get_matome_url_list";
|
|
6
|
-
description = "Matomeに登録したurlを取得する";
|
|
7
|
-
MATOME_API_BASE = "https://matome.ebi-generator.com/api/mcp";
|
|
8
|
-
schema = {
|
|
9
|
-
message: {
|
|
10
|
-
type: z.string(),
|
|
11
|
-
description: "Message to process",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
async execute() {
|
|
15
|
-
try {
|
|
16
|
-
const Url = `${this.MATOME_API_BASE}`;
|
|
17
|
-
const UID = process.env.USER_ID;
|
|
18
|
-
const response = await fetch(Url, {
|
|
19
|
-
method: "POST",
|
|
20
|
-
headers: {
|
|
21
|
-
"Content-Type": "application/json",
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify({ uid: UID }),
|
|
24
|
-
});
|
|
25
|
-
if (response.status !== 200) {
|
|
26
|
-
return { content: [{ type: "text", text: "matome fetch Error!!" }] };
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const result = await response.json();
|
|
30
|
-
// const resultlist: BASE_CONTENT = { content: [] };
|
|
31
|
-
// result.list.forEach((item) => {
|
|
32
|
-
// resultlist.content.push({ type: "text", text: item.url });
|
|
33
|
-
// });
|
|
34
|
-
// return resultlist;
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return {
|
|
40
|
-
list: [{ type: "error", url: "" }],
|
|
41
|
-
// content: [
|
|
42
|
-
// {
|
|
43
|
-
// type: "text",
|
|
44
|
-
// text: "matome url list is none",
|
|
45
|
-
// },
|
|
46
|
-
// ],
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export default MatomeTool;
|