@hypothesi/tauri-mcp-server 0.9.0 → 0.11.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/dist/server.js ADDED
@@ -0,0 +1,110 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
4
+ import { zodToJsonSchema } from 'zod-to-json-schema';
5
+ import { TOOLS, TOOL_MAP } from './tools-registry.js';
6
+ import { PROMPTS, PROMPT_MAP } from './prompts-registry.js';
7
+ import { createMcpLogger } from './logger.js';
8
+ /* eslint-disable no-process-exit */
9
+ const serverLogger = createMcpLogger('SERVER');
10
+ export function getCliToolDefinitions() {
11
+ return TOOLS.map((tool) => {
12
+ return {
13
+ name: tool.name,
14
+ description: tool.description,
15
+ inputSchema: zodToJsonSchema(tool.schema),
16
+ };
17
+ });
18
+ }
19
+ function toolResultToContent(result) {
20
+ if (typeof result === 'string') {
21
+ return [{ type: 'text', text: result }];
22
+ }
23
+ if (Array.isArray(result)) {
24
+ return result.map(contentToMcp);
25
+ }
26
+ return [contentToMcp(result)];
27
+ }
28
+ function contentToMcp(content) {
29
+ if (content.type === 'text') {
30
+ return { type: 'text', text: content.text };
31
+ }
32
+ return { type: 'image', data: content.data, mimeType: content.mimeType };
33
+ }
34
+ export function createMcpServer(info) {
35
+ const server = new Server({
36
+ name: info.name,
37
+ version: info.version,
38
+ }, {
39
+ capabilities: {
40
+ tools: {},
41
+ prompts: {},
42
+ },
43
+ });
44
+ server.onerror = (error) => {
45
+ const message = error instanceof Error ? error.message : String(error);
46
+ if (message.includes('broken pipe') || message.includes('EPIPE')) {
47
+ process.exit(0);
48
+ }
49
+ serverLogger.error(message);
50
+ };
51
+ server.onclose = () => {
52
+ process.exit(0);
53
+ };
54
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
55
+ return {
56
+ tools: TOOLS.map((tool) => {
57
+ return {
58
+ name: tool.name,
59
+ description: tool.description,
60
+ inputSchema: zodToJsonSchema(tool.schema),
61
+ annotations: tool.annotations,
62
+ };
63
+ }),
64
+ };
65
+ });
66
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
67
+ try {
68
+ const tool = TOOL_MAP.get(request.params.name);
69
+ if (!tool) {
70
+ throw new Error(`Unknown tool: ${request.params.name}`);
71
+ }
72
+ const output = await tool.handler(request.params.arguments);
73
+ return { content: toolResultToContent(output) };
74
+ }
75
+ catch (error) {
76
+ const message = error instanceof Error ? error.message : String(error);
77
+ return {
78
+ content: [{ type: 'text', text: `Error: ${message}` }],
79
+ isError: true,
80
+ };
81
+ }
82
+ });
83
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
84
+ return {
85
+ prompts: PROMPTS.map((prompt) => {
86
+ return {
87
+ name: prompt.name,
88
+ description: prompt.description,
89
+ arguments: prompt.arguments,
90
+ };
91
+ }),
92
+ };
93
+ });
94
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
95
+ const prompt = PROMPT_MAP.get(request.params.name);
96
+ if (!prompt) {
97
+ throw new Error(`Unknown prompt: ${request.params.name}`);
98
+ }
99
+ const args = (request.params.arguments || {});
100
+ return {
101
+ description: prompt.description,
102
+ messages: prompt.handler(args),
103
+ };
104
+ });
105
+ return server;
106
+ }
107
+ export async function startStdioServer(info) {
108
+ const transport = new StdioServerTransport(), server = createMcpServer(info);
109
+ await server.connect(transport);
110
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Single source of truth for all MCP tool definitions
3
+ * This file defines all available tools and their metadata
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Content types that tools can return.
8
+ * Text content is the default, image content is used for screenshots.
9
+ */
10
+ export interface TextContent {
11
+ type: 'text';
12
+ text: string;
13
+ }
14
+ export interface ImageContent {
15
+ type: 'image';
16
+ data: string;
17
+ mimeType: string;
18
+ }
19
+ export type ToolContent = TextContent | ImageContent;
20
+ /**
21
+ * Tool result can be a string (legacy, converted to TextContent) or structured content.
22
+ */
23
+ export type ToolResult = string | ToolContent | ToolContent[];
24
+ export type ToolHandler = (args: unknown) => Promise<ToolResult>;
25
+ /**
26
+ * Tool annotations that help the AI understand when and how to use tools.
27
+ * These follow the MCP specification for ToolAnnotations.
28
+ */
29
+ export interface ToolAnnotations {
30
+ title?: string;
31
+ readOnlyHint?: boolean;
32
+ destructiveHint?: boolean;
33
+ idempotentHint?: boolean;
34
+ openWorldHint?: boolean;
35
+ }
36
+ export interface ToolDefinition {
37
+ name: string;
38
+ description: string;
39
+ category: string;
40
+ schema: z.ZodSchema;
41
+ handler: ToolHandler;
42
+ annotations?: ToolAnnotations;
43
+ }
44
+ /**
45
+ * Tool categories for organization
46
+ */
47
+ export declare const TOOL_CATEGORIES: {
48
+ readonly SETUP: "Setup & Configuration";
49
+ readonly MOBILE_DEVELOPMENT: "Mobile Development";
50
+ readonly UI_AUTOMATION: "UI Automation & WebView Interaction";
51
+ readonly IPC_PLUGIN: "IPC & Plugin Tools (via MCP Bridge)";
52
+ };
53
+ /**
54
+ * Complete registry of all available tools
55
+ * This is the single source of truth for tool definitions
56
+ */
57
+ export declare const TOOLS: ToolDefinition[];
58
+ /**
59
+ * Get all tool names for type checking
60
+ */
61
+ export type ToolName = typeof TOOLS[number]['name'];
62
+ /**
63
+ * Get tools grouped by category
64
+ */
65
+ export declare function getToolsByCategory(): Record<string, ToolDefinition[]>;
66
+ /**
67
+ * Get total tool count
68
+ */
69
+ export declare function getToolCount(): number;
70
+ /**
71
+ * Create a Map for fast tool lookup by name
72
+ */
73
+ export declare const TOOL_MAP: Map<string, ToolDefinition>;
@@ -171,6 +171,7 @@ export const TOOLS = [
171
171
  name: 'webview_find_element',
172
172
  description: '[Tauri Apps Only] Find DOM elements in a running Tauri app\'s webview. ' +
173
173
  'Supports CSS selectors (default), XPath expressions, and text content matching via the strategy parameter. ' +
174
+ 'The "text" strategy first searches element text content, then falls back to placeholder, aria-label, and title attributes. ' +
174
175
  'Returns the element\'s HTML. ' +
175
176
  'Requires active driver_session. ' +
176
177
  MULTI_APP_DESC + ' ' +
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Window type definitions for multi-webview support.
3
+ */
4
+ /**
5
+ * Information about a webview window.
6
+ */
7
+ export interface WindowInfo {
8
+ label: string;
9
+ title?: string;
10
+ url?: string;
11
+ focused: boolean;
12
+ visible: boolean;
13
+ isMain: boolean;
14
+ }
15
+ /**
16
+ * Response from the list_windows command.
17
+ */
18
+ export interface ListWindowsResponse {
19
+ windows: WindowInfo[];
20
+ defaultWindow: string;
21
+ totalCount: number;
22
+ }
23
+ /**
24
+ * Context about which window was used for an operation.
25
+ */
26
+ export interface WindowContext {
27
+ windowLabel: string;
28
+ totalWindows: number;
29
+ warning?: string;
30
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Version information for the MCP Bridge plugin.
3
+ *
4
+ * Reads the version from this package's package.json at runtime.
5
+ * Both packages share the same version (monorepo single-version policy).
6
+ */
7
+ /**
8
+ * Full version string (e.g., "0.6.5")
9
+ */
10
+ export declare const PLUGIN_VERSION_FULL: string;
11
+ /**
12
+ * Cargo-compatible version string for Cargo.toml dependencies (e.g., "0.6")
13
+ * This is the major.minor version used in Cargo.toml dependency specifications.
14
+ */
15
+ export declare const PLUGIN_VERSION_CARGO: string;
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@hypothesi/tauri-mcp-server",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "mcpName": "io.github.hypothesi/mcp-server-tauri",
5
5
  "description": "A Model Context Protocol server for use with Tauri v2 applications",
6
6
  "type": "module",
7
+ "main": "./dist/api.js",
8
+ "types": "./dist/api.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/api.js",
12
+ "types": "./dist/api.d.ts"
13
+ }
14
+ },
7
15
  "bin": {
8
16
  "mcp-server-tauri": "./dist/index.js"
9
17
  },