@esaio/esa-mcp-server 0.1.0
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/.claude/settings.local.json +23 -0
- package/.dockerignore +36 -0
- package/.envrc +2 -0
- package/.github/dependabot.yml +18 -0
- package/.github/workflows/docker-publish.yml +120 -0
- package/.github/workflows/main.yml +41 -0
- package/.node-version +1 -0
- package/CLAUDE.md +94 -0
- package/Dockerfile +34 -0
- package/LICENSE +7 -0
- package/README.en.md +139 -0
- package/README.md +139 -0
- package/bin/index.js +30 -0
- package/biome.json +57 -0
- package/package.json +48 -0
- package/src/__tests__/fixtures/mock-comment.ts +90 -0
- package/src/__tests__/fixtures/mock-post.ts +79 -0
- package/src/__tests__/index.test.ts +209 -0
- package/src/api_client/__tests__/index.test.ts +149 -0
- package/src/api_client/__tests__/middleware.test.ts +119 -0
- package/src/api_client/__tests__/with-context.test.ts +98 -0
- package/src/api_client/index.ts +29 -0
- package/src/api_client/middleware.ts +21 -0
- package/src/api_client/with-context.ts +26 -0
- package/src/config/__tests__/index.test.ts +65 -0
- package/src/config/index.ts +20 -0
- package/src/context/mcp-context.ts +1 -0
- package/src/context/stdio-context.ts +6 -0
- package/src/errors/missing-team-name-error.ts +8 -0
- package/src/formatters/__tests__/mcp-response.test.ts +106 -0
- package/src/formatters/mcp-response.ts +95 -0
- package/src/generated/api-types.ts +2691 -0
- package/src/i18n/__tests__/index.test.ts +53 -0
- package/src/i18n/index.ts +39 -0
- package/src/index.ts +47 -0
- package/src/locales/en.json +13 -0
- package/src/locales/ja.json +13 -0
- package/src/prompts/__tests__/index.test.ts +47 -0
- package/src/prompts/__tests__/summarize-post.test.ts +291 -0
- package/src/prompts/index.ts +21 -0
- package/src/prompts/summarize-post.ts +94 -0
- package/src/resources/__tests__/index.test.ts +49 -0
- package/src/resources/__tests__/recent-posts-list.test.ts +91 -0
- package/src/resources/__tests__/recent-posts.test.ts +270 -0
- package/src/resources/index.ts +33 -0
- package/src/resources/recent-posts-list.ts +22 -0
- package/src/resources/recent-posts.ts +45 -0
- package/src/schemas/team-name-schema.ts +19 -0
- package/src/tools/__tests__/categories.test.ts +226 -0
- package/src/tools/__tests__/comments.test.ts +970 -0
- package/src/tools/__tests__/helps.test.ts +222 -0
- package/src/tools/__tests__/index.test.ts +47 -0
- package/src/tools/__tests__/post-actions.test.ts +445 -0
- package/src/tools/__tests__/posts.test.ts +917 -0
- package/src/tools/__tests__/search.test.ts +339 -0
- package/src/tools/__tests__/teams.test.ts +615 -0
- package/src/tools/categories.ts +93 -0
- package/src/tools/comments.ts +258 -0
- package/src/tools/helps.ts +50 -0
- package/src/tools/index.ts +324 -0
- package/src/tools/post-actions.ts +132 -0
- package/src/tools/posts.ts +179 -0
- package/src/tools/search.ts +98 -0
- package/src/tools/teams.ts +157 -0
- package/src/transformers/__tests__/category-transformer.test.ts +161 -0
- package/src/transformers/__tests__/comment-transformer.test.ts +129 -0
- package/src/transformers/__tests__/post-name-normalizer.test.ts +53 -0
- package/src/transformers/__tests__/post-transformer.test.ts +70 -0
- package/src/transformers/__tests__/query-normalizer.test.ts +98 -0
- package/src/transformers/__tests__/team-name-normalizer.test.ts +21 -0
- package/src/transformers/category-transformer.ts +36 -0
- package/src/transformers/comment-transformer.ts +34 -0
- package/src/transformers/post-name-normalizer.ts +30 -0
- package/src/transformers/post-transformer.ts +38 -0
- package/src/transformers/query-normalizer.ts +36 -0
- package/src/transformers/team-name-normalizer.ts +7 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +30 -0
- package/tsdown.config.ts +13 -0
- package/vitest.config.ts +24 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CallToolResult,
|
|
3
|
+
GetPromptResult,
|
|
4
|
+
ReadResourceResult,
|
|
5
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
|
|
7
|
+
function formatErrorText(error: unknown): string {
|
|
8
|
+
return error instanceof Error
|
|
9
|
+
? `Error: ${error.message}`
|
|
10
|
+
: typeof error === "number" && error !== null
|
|
11
|
+
? `Error: API Response(status: ${error})`
|
|
12
|
+
: typeof error === "object" && error !== null
|
|
13
|
+
? `Error: ${JSON.stringify(error, null, 2)}`
|
|
14
|
+
: `Error: ${String(error)}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function formatToolResponse(data: unknown): CallToolResult {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: JSON.stringify(data, null, 2),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatResourceResponse(
|
|
29
|
+
data: unknown,
|
|
30
|
+
uri: string,
|
|
31
|
+
): ReadResourceResult {
|
|
32
|
+
return {
|
|
33
|
+
contents: [
|
|
34
|
+
{
|
|
35
|
+
uri,
|
|
36
|
+
mimeType: "application/json",
|
|
37
|
+
text: JSON.stringify(data, null, 2),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function formatPromptResponse(message: string): GetPromptResult {
|
|
44
|
+
return {
|
|
45
|
+
messages: [
|
|
46
|
+
{
|
|
47
|
+
role: "user",
|
|
48
|
+
content: {
|
|
49
|
+
type: "text",
|
|
50
|
+
text: message,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function formatToolError(error: unknown): CallToolResult {
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: "text",
|
|
62
|
+
text: formatErrorText(error),
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function formatResourceError(
|
|
69
|
+
error: unknown,
|
|
70
|
+
uri: string,
|
|
71
|
+
): ReadResourceResult {
|
|
72
|
+
return {
|
|
73
|
+
contents: [
|
|
74
|
+
{
|
|
75
|
+
uri,
|
|
76
|
+
mimeType: "application/json",
|
|
77
|
+
text: formatErrorText(error),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function formatPromptError(error: unknown): GetPromptResult {
|
|
84
|
+
return {
|
|
85
|
+
messages: [
|
|
86
|
+
{
|
|
87
|
+
role: "user",
|
|
88
|
+
content: {
|
|
89
|
+
type: "text",
|
|
90
|
+
text: formatErrorText(error),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|