@air-jam/mcp-server 0.9.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/LICENSE +21 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +8284 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +259 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8081 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +8015 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +51 -0
- package/dist/tools.js +7910 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
- package/src/cli.ts +22 -0
- package/src/config.ts +73 -0
- package/src/index.ts +4 -0
- package/src/server.ts +145 -0
- package/src/tools.ts +606 -0
- package/src/types.ts +17 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type AirJamProjectLocalMcpConfig = {
|
|
2
|
+
mcpServers: {
|
|
3
|
+
airjam: {
|
|
4
|
+
command: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type InspectMcpProjectSetupResult = {
|
|
10
|
+
projectDir: string;
|
|
11
|
+
configPath: string;
|
|
12
|
+
hasConfigFile: boolean;
|
|
13
|
+
hasMcpScript: boolean;
|
|
14
|
+
hasMcpDependency: boolean;
|
|
15
|
+
recommendedConfig: AirJamProjectLocalMcpConfig;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type { AirJamProjectLocalMcpConfig, InspectMcpProjectSetupResult };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@air-jam/mcp-server",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Official Air Jam MCP server for project inspection, logs, quality gates, and visual artifacts",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/vucinatim/airjam.git",
|
|
11
|
+
"directory": "packages/mcp-server"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/vucinatim/airjam#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/vucinatim/airjam/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"airjam-mcp": "./dist/cli.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./config": {
|
|
32
|
+
"types": "./dist/config.d.ts",
|
|
33
|
+
"import": "./dist/config.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"src"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
42
|
+
"socket.io-client": "^4.8.1",
|
|
43
|
+
"zod": "^4.2.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^24.10.1",
|
|
47
|
+
"tsup": "^8.5.1",
|
|
48
|
+
"typescript": "~5.9.3",
|
|
49
|
+
"vitest": "^3.2.4"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/devtools-core && tsup",
|
|
53
|
+
"test": "vitest run --config vitest.config.ts",
|
|
54
|
+
"test:watch": "vitest --config vitest.config.ts",
|
|
55
|
+
"typecheck": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/devtools-core && tsc --noEmit && tsc -p tests/tsconfig.json --noEmit"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
|
|
3
|
+
const HELP_TEXT = `Usage: airjam-mcp [options]
|
|
4
|
+
|
|
5
|
+
Official Air Jam MCP server
|
|
6
|
+
|
|
7
|
+
Options:
|
|
8
|
+
--help Show this help text
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
|
|
13
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
14
|
+
process.stdout.write(HELP_TEXT);
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { createAirJamMcpServer } = await import("./server.js");
|
|
19
|
+
const server = await createAirJamMcpServer();
|
|
20
|
+
const transport = new StdioServerTransport();
|
|
21
|
+
|
|
22
|
+
await server.connect(transport);
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { inspectProject } from "@air-jam/devtools-core/context";
|
|
2
|
+
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type {
|
|
5
|
+
AirJamProjectLocalMcpConfig,
|
|
6
|
+
InspectMcpProjectSetupResult,
|
|
7
|
+
} from "./types.js";
|
|
8
|
+
|
|
9
|
+
export const AIRJAM_PROJECT_MCP_FILE = ".mcp.json";
|
|
10
|
+
|
|
11
|
+
export const createProjectLocalMcpConfig = (): AirJamProjectLocalMcpConfig => ({
|
|
12
|
+
mcpServers: {
|
|
13
|
+
airjam: {
|
|
14
|
+
command: "pnpm",
|
|
15
|
+
args: ["exec", "airjam-mcp"],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const pathExists = async (targetPath: string): Promise<boolean> => {
|
|
21
|
+
try {
|
|
22
|
+
await access(targetPath);
|
|
23
|
+
return true;
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const inspectMcpProjectSetup = async ({
|
|
30
|
+
cwd = process.cwd(),
|
|
31
|
+
}: {
|
|
32
|
+
cwd?: string;
|
|
33
|
+
} = {}): Promise<InspectMcpProjectSetupResult> => {
|
|
34
|
+
const project = await inspectProject({ cwd });
|
|
35
|
+
const configPath = path.join(
|
|
36
|
+
project.context.rootDir,
|
|
37
|
+
AIRJAM_PROJECT_MCP_FILE,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
projectDir: project.context.rootDir,
|
|
42
|
+
configPath,
|
|
43
|
+
hasConfigFile: await pathExists(configPath),
|
|
44
|
+
hasMcpScript: Boolean(project.scripts.mcp),
|
|
45
|
+
hasMcpDependency: Boolean(project.airJamPackages["@air-jam/mcp-server"]),
|
|
46
|
+
recommendedConfig: createProjectLocalMcpConfig(),
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const writeProjectLocalMcpConfig = async ({
|
|
51
|
+
cwd = process.cwd(),
|
|
52
|
+
force = false,
|
|
53
|
+
}: {
|
|
54
|
+
cwd?: string;
|
|
55
|
+
force?: boolean;
|
|
56
|
+
} = {}): Promise<InspectMcpProjectSetupResult> => {
|
|
57
|
+
const inspection = await inspectMcpProjectSetup({ cwd });
|
|
58
|
+
|
|
59
|
+
if (inspection.hasConfigFile && !force) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`MCP config already exists at ${inspection.configPath}. Re-run with force to overwrite it.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await mkdir(path.dirname(inspection.configPath), { recursive: true });
|
|
66
|
+
await writeFile(
|
|
67
|
+
inspection.configPath,
|
|
68
|
+
`${JSON.stringify(inspection.recommendedConfig, null, 2)}\n`,
|
|
69
|
+
"utf8",
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return inspectMcpProjectSetup({ cwd });
|
|
73
|
+
};
|
package/src/index.ts
ADDED
package/src/server.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { detectProjectContext } from "@air-jam/devtools-core/context";
|
|
2
|
+
import type {
|
|
3
|
+
CreateTaskRequestHandlerExtra,
|
|
4
|
+
TaskRequestHandlerExtra,
|
|
5
|
+
} from "@modelcontextprotocol/sdk/experimental/tasks";
|
|
6
|
+
import { InMemoryTaskStore } from "@modelcontextprotocol/sdk/experimental/tasks";
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import {
|
|
10
|
+
buildToolDefinitions,
|
|
11
|
+
getRegisteredToolNamesForProjectMode,
|
|
12
|
+
} from "./tools.js";
|
|
13
|
+
|
|
14
|
+
const DEFAULT_TASK_TTL_MS = 5 * 60 * 1000;
|
|
15
|
+
const TASK_CAPABLE_CLIENT_NOTE =
|
|
16
|
+
" Requires an MCP client with task-backed tool execution support.";
|
|
17
|
+
|
|
18
|
+
const describeToolForRegistration = ({
|
|
19
|
+
description,
|
|
20
|
+
requiresTaskSupport,
|
|
21
|
+
}: {
|
|
22
|
+
description: string;
|
|
23
|
+
requiresTaskSupport: boolean;
|
|
24
|
+
}): string =>
|
|
25
|
+
requiresTaskSupport
|
|
26
|
+
? `${description}${TASK_CAPABLE_CLIENT_NOTE}`
|
|
27
|
+
: description;
|
|
28
|
+
|
|
29
|
+
const createToolErrorResult = (error: unknown): CallToolResult => ({
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: "text",
|
|
33
|
+
text:
|
|
34
|
+
error instanceof Error
|
|
35
|
+
? error.message
|
|
36
|
+
: `Air Jam MCP task failed: ${String(error)}`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
isError: true,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const createAirJamMcpServer = async ({
|
|
43
|
+
cwd = process.cwd(),
|
|
44
|
+
}: {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
} = {}): Promise<McpServer> => {
|
|
47
|
+
const context = await detectProjectContext({ cwd });
|
|
48
|
+
const toolDefinitions = buildToolDefinitions({
|
|
49
|
+
projectMode: context.mode,
|
|
50
|
+
});
|
|
51
|
+
const registeredToolNames = getRegisteredToolNamesForProjectMode(
|
|
52
|
+
context.mode,
|
|
53
|
+
);
|
|
54
|
+
const taskStore = new InMemoryTaskStore();
|
|
55
|
+
const server = new McpServer(
|
|
56
|
+
{
|
|
57
|
+
name: "air-jam",
|
|
58
|
+
version: "1.0.0",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
capabilities: {
|
|
62
|
+
tasks: {
|
|
63
|
+
list: {},
|
|
64
|
+
cancel: {},
|
|
65
|
+
requests: {
|
|
66
|
+
tools: {
|
|
67
|
+
call: {},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
instructions:
|
|
73
|
+
"Use Air Jam tools before falling back to raw shell commands for Air Jam-native workflows. Start with inspect_project, read_logs with view=signal, and inspect_game when debugging runtime or game issues. If a tool advertises task-backed execution support as required, call it through an MCP client flow that supports tasks instead of assuming one blocking request/response call.",
|
|
74
|
+
taskStore,
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
for (const toolName of registeredToolNames) {
|
|
79
|
+
const tool = toolDefinitions[toolName];
|
|
80
|
+
const description = describeToolForRegistration({
|
|
81
|
+
description: tool.description,
|
|
82
|
+
requiresTaskSupport: tool.execution?.taskSupport === "required",
|
|
83
|
+
});
|
|
84
|
+
const baseConfig = {
|
|
85
|
+
description,
|
|
86
|
+
inputSchema: tool.inputSchema,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
if (tool.execution?.taskSupport === "required") {
|
|
90
|
+
server.experimental.tasks.registerToolTask(
|
|
91
|
+
toolName,
|
|
92
|
+
{
|
|
93
|
+
...baseConfig,
|
|
94
|
+
execution: {
|
|
95
|
+
taskSupport: "required",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
createTask: async (
|
|
100
|
+
args: unknown,
|
|
101
|
+
{ taskStore, taskRequestedTtl }: CreateTaskRequestHandlerExtra,
|
|
102
|
+
) => {
|
|
103
|
+
const task = await taskStore.createTask({
|
|
104
|
+
ttl: taskRequestedTtl ?? DEFAULT_TASK_TTL_MS,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
void (async () => {
|
|
108
|
+
try {
|
|
109
|
+
const result = await tool.run(args as never);
|
|
110
|
+
await taskStore.storeTaskResult(
|
|
111
|
+
task.taskId,
|
|
112
|
+
"completed",
|
|
113
|
+
result,
|
|
114
|
+
);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
await taskStore.storeTaskResult(
|
|
117
|
+
task.taskId,
|
|
118
|
+
"failed",
|
|
119
|
+
createToolErrorResult(error),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
})();
|
|
123
|
+
|
|
124
|
+
return { task };
|
|
125
|
+
},
|
|
126
|
+
getTask: async (
|
|
127
|
+
_args: unknown,
|
|
128
|
+
{ taskId, taskStore }: TaskRequestHandlerExtra,
|
|
129
|
+
) => taskStore.getTask(taskId),
|
|
130
|
+
getTaskResult: async (
|
|
131
|
+
_args: unknown,
|
|
132
|
+
{ taskId, taskStore }: TaskRequestHandlerExtra,
|
|
133
|
+
) => taskStore.getTaskResult(taskId) as Promise<CallToolResult>,
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
server.registerTool(toolName, baseConfig, async (args: unknown) =>
|
|
140
|
+
tool.run(args as never),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return server;
|
|
145
|
+
};
|