@nahisaho/katashiro-mcp-server 2.0.1 → 2.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nahisaho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * KATASHIRO MCP Server CLI
4
+ *
5
+ * Entry point for running the MCP server via STDIO transport
6
+ *
7
+ * Usage:
8
+ * npx @nahisaho/katashiro-mcp-server
9
+ * katashiro-mcp-server
10
+ *
11
+ * @module @nahisaho/katashiro-mcp-server
12
+ * @task TSK-062
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names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,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC;AAED,WAAW;AACX,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @nahisaho/katashiro-mcp-server
3
+ * MCP (Model Context Protocol) サーバー実装
4
+ *
5
+ * Official MCP Specification: https://modelcontextprotocol.io
6
+ *
7
+ * @design DES-KATASHIRO-001 §2.4 MCP Server
8
+ */
9
+ export { KatashiroMCPServer } from './server/mcp-server.js';
10
+ export type { MCPTool, MCPPrompt, MCPResource, ToolResult, PromptResult, ServerCapabilities, ServerInfo, } from './server/mcp-server.js';
11
+ export { StdioTransport, createSuccessResponse, createErrorResponse, JsonRpcErrorCode, } from './transport/index.js';
12
+ export type { JsonRpcRequest, JsonRpcNotification, JsonRpcResponse, JsonRpcError, MessageHandler, TransportState, } from './transport/index.js';
13
+ export { MCPProtocolHandler, MCP_PROTOCOL_VERSION } from './protocol/index.js';
14
+ export type { InitializeParams, InitializeResult, ToolsListResult, ToolsCallParams, ResourcesListResult, ResourcesReadParams, PromptsListResult, PromptsGetParams, ProtocolState, } from './protocol/index.js';
15
+ export { ToolRegistry } from './tools/tool-registry.js';
16
+ export type { ToolContent, ToolExecutionResult, ToolHandler, RegisteredTool, } from './tools/tool-registry.js';
17
+ export { PromptRegistry } from './prompts/prompt-registry.js';
18
+ export type { PromptArgument, RegisteredPrompt, ValidationResult, } from './prompts/prompt-registry.js';
19
+ export { ResourceManager } from './resources/resource-manager.js';
20
+ export type { ResourceContent, ContentProvider, ResourceDefinition, ResourceTemplate, SubscriptionCallback, } from './resources/resource-manager.js';
21
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @nahisaho/katashiro-mcp-server
3
+ * MCP (Model Context Protocol) サーバー実装
4
+ *
5
+ * Official MCP Specification: https://modelcontextprotocol.io
6
+ *
7
+ * @design DES-KATASHIRO-001 §2.4 MCP Server
8
+ */
9
+ // Server
10
+ export { KatashiroMCPServer } from './server/mcp-server.js';
11
+ // Transport
12
+ export { StdioTransport, createSuccessResponse, createErrorResponse, JsonRpcErrorCode, } from './transport/index.js';
13
+ // Protocol
14
+ export { MCPProtocolHandler, MCP_PROTOCOL_VERSION } from './protocol/index.js';
15
+ // Tools (legacy, for backward compatibility)
16
+ export { ToolRegistry } from './tools/tool-registry.js';
17
+ // Prompts (legacy, for backward compatibility)
18
+ export { PromptRegistry } from './prompts/prompt-registry.js';
19
+ // Resources (legacy, for backward compatibility)
20
+ export { ResourceManager } from './resources/resource-manager.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAW5D,YAAY;AACZ,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAU9B,WAAW;AACX,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAa/E,6CAA6C;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQxD,+CAA+C;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAO9D,iDAAiD;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * PromptRegistry - プロンプト登録・管理
3
+ *
4
+ * MCPプロンプトの登録と実行を管理
5
+ *
6
+ * @module @nahisaho/katashiro-mcp-server
7
+ * @task TSK-062
8
+ */
9
+ import { type Result } from '@nahisaho/katashiro-core';
10
+ /**
11
+ * Prompt argument definition
12
+ */
13
+ export interface PromptArgument {
14
+ name: string;
15
+ description: string;
16
+ required?: boolean;
17
+ }
18
+ /**
19
+ * Registered prompt
20
+ */
21
+ export interface RegisteredPrompt {
22
+ name: string;
23
+ description: string;
24
+ template: string;
25
+ arguments?: PromptArgument[];
26
+ }
27
+ /**
28
+ * Validation result
29
+ */
30
+ export interface ValidationResult {
31
+ valid: boolean;
32
+ missing: string[];
33
+ extra: string[];
34
+ }
35
+ /**
36
+ * PromptRegistry
37
+ *
38
+ * Manages MCP prompt registration and rendering
39
+ */
40
+ export declare class PromptRegistry {
41
+ private prompts;
42
+ /**
43
+ * Register a prompt
44
+ *
45
+ * @param prompt - Prompt to register
46
+ * @returns Result
47
+ */
48
+ register(prompt: RegisteredPrompt): Result<void, Error>;
49
+ /**
50
+ * Get a registered prompt
51
+ *
52
+ * @param name - Prompt name
53
+ * @returns Prompt or null
54
+ */
55
+ get(name: string): Result<RegisteredPrompt | null, Error>;
56
+ /**
57
+ * List all registered prompts
58
+ *
59
+ * @returns Array of prompts
60
+ */
61
+ list(): Result<RegisteredPrompt[], Error>;
62
+ /**
63
+ * Render a prompt with arguments
64
+ *
65
+ * @param name - Prompt name
66
+ * @param args - Arguments to fill in
67
+ * @returns Rendered template
68
+ */
69
+ render(name: string, args: Record<string, string>): Result<string, Error>;
70
+ /**
71
+ * Validate arguments for a prompt
72
+ *
73
+ * @param name - Prompt name
74
+ * @param args - Arguments to validate
75
+ * @returns Validation result
76
+ */
77
+ validate(name: string, args: Record<string, unknown>): Result<ValidationResult, Error>;
78
+ /**
79
+ * Unregister a prompt
80
+ *
81
+ * @param name - Prompt name
82
+ * @returns Whether unregistered
83
+ */
84
+ unregister(name: string): Result<boolean, Error>;
85
+ /**
86
+ * Check if prompt exists
87
+ *
88
+ * @param name - Prompt name
89
+ * @returns Whether exists
90
+ */
91
+ has(name: string): boolean;
92
+ /**
93
+ * Clear all prompts
94
+ */
95
+ clear(): void;
96
+ }
97
+ //# sourceMappingURL=prompt-registry.d.ts.map
@@ -0,0 +1,155 @@
1
+ /**
2
+ * PromptRegistry - プロンプト登録・管理
3
+ *
4
+ * MCPプロンプトの登録と実行を管理
5
+ *
6
+ * @module @nahisaho/katashiro-mcp-server
7
+ * @task TSK-062
8
+ */
9
+ import { ok, err } from '@nahisaho/katashiro-core';
10
+ /**
11
+ * PromptRegistry
12
+ *
13
+ * Manages MCP prompt registration and rendering
14
+ */
15
+ export class PromptRegistry {
16
+ prompts = new Map();
17
+ /**
18
+ * Register a prompt
19
+ *
20
+ * @param prompt - Prompt to register
21
+ * @returns Result
22
+ */
23
+ register(prompt) {
24
+ try {
25
+ if (this.prompts.has(prompt.name)) {
26
+ return err(new Error(`Prompt already registered: ${prompt.name}`));
27
+ }
28
+ this.prompts.set(prompt.name, prompt);
29
+ return ok(undefined);
30
+ }
31
+ catch (error) {
32
+ return err(error instanceof Error ? error : new Error(String(error)));
33
+ }
34
+ }
35
+ /**
36
+ * Get a registered prompt
37
+ *
38
+ * @param name - Prompt name
39
+ * @returns Prompt or null
40
+ */
41
+ get(name) {
42
+ try {
43
+ return ok(this.prompts.get(name) ?? null);
44
+ }
45
+ catch (error) {
46
+ return err(error instanceof Error ? error : new Error(String(error)));
47
+ }
48
+ }
49
+ /**
50
+ * List all registered prompts
51
+ *
52
+ * @returns Array of prompts
53
+ */
54
+ list() {
55
+ try {
56
+ return ok(Array.from(this.prompts.values()));
57
+ }
58
+ catch (error) {
59
+ return err(error instanceof Error ? error : new Error(String(error)));
60
+ }
61
+ }
62
+ /**
63
+ * Render a prompt with arguments
64
+ *
65
+ * @param name - Prompt name
66
+ * @param args - Arguments to fill in
67
+ * @returns Rendered template
68
+ */
69
+ render(name, args) {
70
+ try {
71
+ const prompt = this.prompts.get(name);
72
+ if (!prompt) {
73
+ return err(new Error(`Unknown prompt: ${name}`));
74
+ }
75
+ let rendered = prompt.template;
76
+ for (const [key, value] of Object.entries(args)) {
77
+ rendered = rendered.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
78
+ }
79
+ return ok(rendered);
80
+ }
81
+ catch (error) {
82
+ return err(error instanceof Error ? error : new Error(String(error)));
83
+ }
84
+ }
85
+ /**
86
+ * Validate arguments for a prompt
87
+ *
88
+ * @param name - Prompt name
89
+ * @param args - Arguments to validate
90
+ * @returns Validation result
91
+ */
92
+ validate(name, args) {
93
+ try {
94
+ const prompt = this.prompts.get(name);
95
+ if (!prompt) {
96
+ return err(new Error(`Unknown prompt: ${name}`));
97
+ }
98
+ const missing = [];
99
+ const extra = [];
100
+ // Check for missing required arguments
101
+ if (prompt.arguments) {
102
+ for (const arg of prompt.arguments) {
103
+ if (arg.required && !(arg.name in args)) {
104
+ missing.push(arg.name);
105
+ }
106
+ }
107
+ // Check for extra arguments
108
+ const validNames = new Set(prompt.arguments.map((a) => a.name));
109
+ for (const key of Object.keys(args)) {
110
+ if (!validNames.has(key)) {
111
+ extra.push(key);
112
+ }
113
+ }
114
+ }
115
+ return ok({
116
+ valid: missing.length === 0,
117
+ missing,
118
+ extra,
119
+ });
120
+ }
121
+ catch (error) {
122
+ return err(error instanceof Error ? error : new Error(String(error)));
123
+ }
124
+ }
125
+ /**
126
+ * Unregister a prompt
127
+ *
128
+ * @param name - Prompt name
129
+ * @returns Whether unregistered
130
+ */
131
+ unregister(name) {
132
+ try {
133
+ return ok(this.prompts.delete(name));
134
+ }
135
+ catch (error) {
136
+ return err(error instanceof Error ? error : new Error(String(error)));
137
+ }
138
+ }
139
+ /**
140
+ * Check if prompt exists
141
+ *
142
+ * @param name - Prompt name
143
+ * @returns Whether exists
144
+ */
145
+ has(name) {
146
+ return this.prompts.has(name);
147
+ }
148
+ /**
149
+ * Clear all prompts
150
+ */
151
+ clear() {
152
+ this.prompts.clear();
153
+ }
154
+ }
155
+ //# sourceMappingURL=prompt-registry.js.map
@@ -0,0 +1 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CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Protocol module exports
3
+ */
4
+ export * from './protocol-handler.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Protocol module exports
3
+ */
4
+ export * from './protocol-handler.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * MCPProtocolHandler - MCP Protocol implementation
3
+ *
4
+ * Implements the Model Context Protocol JSON-RPC handlers
5
+ * Handles lifecycle, tools, resources, and prompts methods
6
+ *
7
+ * @module @nahisaho/katashiro-mcp-server
8
+ * @task TSK-061
9
+ */
10
+ import type { KatashiroMCPServer, ServerCapabilities, ServerInfo } from '../server/mcp-server.js';
11
+ import { type JsonRpcRequest, type JsonRpcResponse, type JsonRpcNotification } from '../transport/stdio-transport.js';
12
+ /**
13
+ * MCP Protocol version
14
+ */
15
+ export declare const MCP_PROTOCOL_VERSION = "2024-11-05";
16
+ /**
17
+ * Initialize request params
18
+ */
19
+ export interface InitializeParams {
20
+ protocolVersion: string;
21
+ capabilities: Record<string, unknown>;
22
+ clientInfo: {
23
+ name: string;
24
+ version: string;
25
+ };
26
+ }
27
+ /**
28
+ * Initialize result
29
+ */
30
+ export interface InitializeResult {
31
+ protocolVersion: string;
32
+ capabilities: ServerCapabilities;
33
+ serverInfo: ServerInfo;
34
+ }
35
+ /**
36
+ * Tools/list result
37
+ */
38
+ export interface ToolsListResult {
39
+ tools: Array<{
40
+ name: string;
41
+ description: string;
42
+ inputSchema: unknown;
43
+ }>;
44
+ }
45
+ /**
46
+ * Tools/call params
47
+ */
48
+ export interface ToolsCallParams {
49
+ name: string;
50
+ arguments?: Record<string, unknown>;
51
+ }
52
+ /**
53
+ * Resources/list result
54
+ */
55
+ export interface ResourcesListResult {
56
+ resources: Array<{
57
+ uri: string;
58
+ name: string;
59
+ description?: string;
60
+ mimeType?: string;
61
+ }>;
62
+ }
63
+ /**
64
+ * Resources/read params
65
+ */
66
+ export interface ResourcesReadParams {
67
+ uri: string;
68
+ }
69
+ /**
70
+ * Prompts/list result
71
+ */
72
+ export interface PromptsListResult {
73
+ prompts: Array<{
74
+ name: string;
75
+ description: string;
76
+ arguments?: Array<{
77
+ name: string;
78
+ description: string;
79
+ required?: boolean;
80
+ }>;
81
+ }>;
82
+ }
83
+ /**
84
+ * Prompts/get params
85
+ */
86
+ export interface PromptsGetParams {
87
+ name: string;
88
+ arguments?: Record<string, unknown>;
89
+ }
90
+ /**
91
+ * Protocol state
92
+ */
93
+ export type ProtocolState = 'uninitialized' | 'initializing' | 'ready' | 'shutdown';
94
+ /**
95
+ * MCPProtocolHandler
96
+ *
97
+ * Handles MCP protocol messages and delegates to KatashiroMCPServer
98
+ */
99
+ export declare class MCPProtocolHandler {
100
+ private readonly server;
101
+ private state;
102
+ private clientInfo;
103
+ constructor(server: KatashiroMCPServer);
104
+ /**
105
+ * Get current protocol state
106
+ */
107
+ getState(): ProtocolState;
108
+ /**
109
+ * Get client info (after initialization)
110
+ */
111
+ getClientInfo(): {
112
+ name: string;
113
+ version: string;
114
+ } | null;
115
+ /**
116
+ * Handle incoming JSON-RPC message
117
+ */
118
+ handleMessage(message: JsonRpcRequest | JsonRpcNotification): Promise<JsonRpcResponse | void>;
119
+ /**
120
+ * Handle notifications
121
+ */
122
+ private handleNotification;
123
+ /**
124
+ * Handle initialize request
125
+ */
126
+ private handleInitialize;
127
+ /**
128
+ * Handle ping request
129
+ */
130
+ private handlePing;
131
+ /**
132
+ * Handle tools/list request
133
+ */
134
+ private handleToolsList;
135
+ /**
136
+ * Handle tools/call request
137
+ */
138
+ private handleToolsCall;
139
+ /**
140
+ * Handle resources/list request
141
+ */
142
+ private handleResourcesList;
143
+ /**
144
+ * Handle resources/read request
145
+ */
146
+ private handleResourcesRead;
147
+ /**
148
+ * Handle prompts/list request
149
+ */
150
+ private handlePromptsList;
151
+ /**
152
+ * Handle prompts/get request
153
+ */
154
+ private handlePromptsGet;
155
+ /**
156
+ * Ensure server is ready for operations
157
+ */
158
+ private ensureReady;
159
+ }
160
+ //# sourceMappingURL=protocol-handler.d.ts.map