motionmcp 1.0.2 → 2.0.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 +202 -0
- package/README.md +242 -446
- package/dist/handlers/CommentHandler.d.ts +9 -0
- package/dist/handlers/CommentHandler.d.ts.map +1 -0
- package/dist/handlers/CommentHandler.js +66 -0
- package/dist/handlers/CommentHandler.js.map +1 -0
- package/dist/handlers/CustomFieldHandler.d.ts +14 -0
- package/dist/handlers/CustomFieldHandler.d.ts.map +1 -0
- package/dist/handlers/CustomFieldHandler.js +95 -0
- package/dist/handlers/CustomFieldHandler.js.map +1 -0
- package/dist/handlers/HandlerFactory.d.ts +15 -0
- package/dist/handlers/HandlerFactory.d.ts.map +1 -0
- package/dist/handlers/HandlerFactory.js +58 -0
- package/dist/handlers/HandlerFactory.js.map +1 -0
- package/dist/handlers/ProjectHandler.d.ts +10 -0
- package/dist/handlers/ProjectHandler.d.ts.map +1 -0
- package/dist/handlers/ProjectHandler.js +63 -0
- package/dist/handlers/ProjectHandler.js.map +1 -0
- package/dist/handlers/RecurringTaskHandler.d.ts +10 -0
- package/dist/handlers/RecurringTaskHandler.d.ts.map +1 -0
- package/dist/handlers/RecurringTaskHandler.js +68 -0
- package/dist/handlers/RecurringTaskHandler.js.map +1 -0
- package/dist/handlers/ScheduleHandler.d.ts +8 -0
- package/dist/handlers/ScheduleHandler.d.ts.map +1 -0
- package/dist/handlers/ScheduleHandler.js +43 -0
- package/dist/handlers/ScheduleHandler.js.map +1 -0
- package/dist/handlers/SearchHandler.d.ts +10 -0
- package/dist/handlers/SearchHandler.d.ts.map +1 -0
- package/dist/handlers/SearchHandler.js +116 -0
- package/dist/handlers/SearchHandler.js.map +1 -0
- package/dist/handlers/StatusHandler.d.ts +8 -0
- package/dist/handlers/StatusHandler.d.ts.map +1 -0
- package/dist/handlers/StatusHandler.js +22 -0
- package/dist/handlers/StatusHandler.js.map +1 -0
- package/dist/handlers/TaskHandler.d.ts +22 -0
- package/dist/handlers/TaskHandler.d.ts.map +1 -0
- package/dist/handlers/TaskHandler.js +266 -0
- package/dist/handlers/TaskHandler.js.map +1 -0
- package/dist/handlers/UserHandler.d.ts +9 -0
- package/dist/handlers/UserHandler.d.ts.map +1 -0
- package/dist/handlers/UserHandler.js +36 -0
- package/dist/handlers/UserHandler.js.map +1 -0
- package/dist/handlers/WorkspaceHandler.d.ts +10 -0
- package/dist/handlers/WorkspaceHandler.d.ts.map +1 -0
- package/dist/handlers/WorkspaceHandler.js +49 -0
- package/dist/handlers/WorkspaceHandler.js.map +1 -0
- package/dist/handlers/base/BaseHandler.d.ts +16 -0
- package/dist/handlers/base/BaseHandler.d.ts.map +1 -0
- package/dist/handlers/base/BaseHandler.js +31 -0
- package/dist/handlers/base/BaseHandler.js.map +1 -0
- package/dist/handlers/base/HandlerInterface.d.ts +18 -0
- package/dist/handlers/base/HandlerInterface.d.ts.map +1 -0
- package/dist/handlers/base/HandlerInterface.js +3 -0
- package/dist/handlers/base/HandlerInterface.js.map +1 -0
- package/dist/handlers/index.d.ts +14 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +31 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/mcp-server-old.d.ts +29 -0
- package/dist/mcp-server-old.d.ts.map +1 -0
- package/dist/mcp-server-old.js +1304 -0
- package/dist/mcp-server-old.js.map +1 -0
- package/dist/mcp-server.d.ts +15 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +145 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/schemas/motion.d.ts +4971 -0
- package/dist/schemas/motion.d.ts.map +1 -0
- package/dist/schemas/motion.js +328 -0
- package/dist/schemas/motion.js.map +1 -0
- package/dist/services/motionApi.d.ts +186 -0
- package/dist/services/motionApi.d.ts.map +1 -0
- package/dist/services/motionApi.js +1912 -0
- package/dist/services/motionApi.js.map +1 -0
- package/dist/tools/ToolConfigurator.d.ts +19 -0
- package/dist/tools/ToolConfigurator.d.ts.map +1 -0
- package/dist/tools/ToolConfigurator.js +89 -0
- package/dist/tools/ToolConfigurator.js.map +1 -0
- package/dist/tools/ToolDefinitions.d.ts +25 -0
- package/dist/tools/ToolDefinitions.d.ts.map +1 -0
- package/dist/tools/ToolDefinitions.js +502 -0
- package/dist/tools/ToolDefinitions.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +16 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +89 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +21 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/mcp-tool-args.d.ts +122 -0
- package/dist/types/mcp-tool-args.d.ts.map +1 -0
- package/dist/types/mcp-tool-args.js +7 -0
- package/dist/types/mcp-tool-args.js.map +1 -0
- package/dist/types/mcp.d.ts +32 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +3 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/motion.d.ts +304 -0
- package/dist/types/motion.d.ts.map +1 -0
- package/dist/types/motion.js +3 -0
- package/dist/types/motion.js.map +1 -0
- package/dist/utils/cache.d.ts +25 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +135 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/constants.d.ts +83 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +151 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +50 -0
- package/dist/utils/errorHandling.d.ts.map +1 -0
- package/dist/utils/errorHandling.js +86 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +38 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +47 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paginationNew.d.ts +44 -0
- package/dist/utils/paginationNew.d.ts.map +1 -0
- package/dist/utils/paginationNew.js +149 -0
- package/dist/utils/paginationNew.js.map +1 -0
- package/dist/utils/parameterUtils.d.ts +79 -0
- package/dist/utils/parameterUtils.d.ts.map +1 -0
- package/dist/utils/parameterUtils.js +189 -0
- package/dist/utils/parameterUtils.js.map +1 -0
- package/dist/utils/responseFormatters.d.ts +92 -0
- package/dist/utils/responseFormatters.d.ts.map +1 -0
- package/dist/utils/responseFormatters.js +331 -0
- package/dist/utils/responseFormatters.js.map +1 -0
- package/dist/utils/responseWrapper.d.ts +38 -0
- package/dist/utils/responseWrapper.d.ts.map +1 -0
- package/dist/utils/responseWrapper.js +201 -0
- package/dist/utils/responseWrapper.js.map +1 -0
- package/dist/utils/sanitize.d.ts +51 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +137 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/validator.d.ts +37 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +74 -0
- package/dist/utils/validator.js.map +1 -0
- package/dist/utils/workspaceResolver.d.ts +40 -0
- package/dist/utils/workspaceResolver.d.ts.map +1 -0
- package/dist/utils/workspaceResolver.js +207 -0
- package/dist/utils/workspaceResolver.js.map +1 -0
- package/package.json +41 -17
- package/.claude/settings.local.json +0 -15
- package/.env.example +0 -3
- package/sample.png +0 -0
- package/src/index.js +0 -179
- package/src/mcp-server.js +0 -1137
- package/src/routes/motion.js +0 -152
- package/src/services/motionApi.js +0 -1177
- package/src/worker.js +0 -248
package/src/index.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const cors = require('cors');
|
|
5
|
-
const winston = require('winston');
|
|
6
|
-
const readline = require('readline');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const os = require('os');
|
|
10
|
-
require('dotenv').config();
|
|
11
|
-
|
|
12
|
-
const motionRoutes = require('./routes/motion');
|
|
13
|
-
|
|
14
|
-
const logger = winston.createLogger({
|
|
15
|
-
level: 'info',
|
|
16
|
-
format: winston.format.combine(
|
|
17
|
-
winston.format.timestamp(),
|
|
18
|
-
winston.format.json()
|
|
19
|
-
),
|
|
20
|
-
transports: [
|
|
21
|
-
new winston.transports.Console({
|
|
22
|
-
format: winston.format.simple()
|
|
23
|
-
})
|
|
24
|
-
]
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Parse command line arguments
|
|
28
|
-
function parseCommandLineArgs() {
|
|
29
|
-
const args = process.argv.slice(2);
|
|
30
|
-
const apiKeyArg = args.find(arg => arg.startsWith('--api-key='));
|
|
31
|
-
if (apiKeyArg) {
|
|
32
|
-
process.env.MOTION_API_KEY = apiKeyArg.split('=')[1];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const portArg = args.find(arg => arg.startsWith('--port='));
|
|
36
|
-
if (portArg) {
|
|
37
|
-
process.env.PORT = portArg.split('=')[1];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Check for config file in user's home directory
|
|
42
|
-
function loadConfigFile() {
|
|
43
|
-
const configPath = path.join(os.homedir(), '.motionmcp.json');
|
|
44
|
-
if (fs.existsSync(configPath)) {
|
|
45
|
-
try {
|
|
46
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
47
|
-
if (config.apiKey && !process.env.MOTION_API_KEY) {
|
|
48
|
-
process.env.MOTION_API_KEY = config.apiKey;
|
|
49
|
-
}
|
|
50
|
-
if (config.port && !process.env.PORT) {
|
|
51
|
-
process.env.PORT = config.port;
|
|
52
|
-
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
logger.warn('Failed to parse config file:', err.message);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Interactive prompt for API key
|
|
60
|
-
async function promptForApiKey() {
|
|
61
|
-
const rl = readline.createInterface({
|
|
62
|
-
input: process.stdin,
|
|
63
|
-
output: process.stdout
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return new Promise((resolve) => {
|
|
67
|
-
rl.question('Please enter your Motion API key: ', (answer) => {
|
|
68
|
-
rl.close();
|
|
69
|
-
const apiKey = answer.trim();
|
|
70
|
-
if (apiKey) {
|
|
71
|
-
process.env.MOTION_API_KEY = apiKey;
|
|
72
|
-
}
|
|
73
|
-
resolve(apiKey);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Get API key from various sources
|
|
79
|
-
async function getApiKey() {
|
|
80
|
-
// Check if already set in environment
|
|
81
|
-
if (process.env.MOTION_API_KEY) {
|
|
82
|
-
return process.env.MOTION_API_KEY;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Parse command line arguments
|
|
86
|
-
parseCommandLineArgs();
|
|
87
|
-
if (process.env.MOTION_API_KEY) {
|
|
88
|
-
return process.env.MOTION_API_KEY;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Load from config file
|
|
92
|
-
loadConfigFile();
|
|
93
|
-
if (process.env.MOTION_API_KEY) {
|
|
94
|
-
return process.env.MOTION_API_KEY;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Prompt user interactively
|
|
98
|
-
logger.info('No API key found in environment variables, command line args, or config file.');
|
|
99
|
-
const apiKey = await promptForApiKey();
|
|
100
|
-
return apiKey;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Initialize and start the server
|
|
104
|
-
async function startServer() {
|
|
105
|
-
try {
|
|
106
|
-
const apiKey = await getApiKey();
|
|
107
|
-
|
|
108
|
-
if (!apiKey) {
|
|
109
|
-
logger.error('API key is required to run Motion MCP Server');
|
|
110
|
-
logger.info('You can provide it via:');
|
|
111
|
-
logger.info(' Environment variable: MOTION_API_KEY=your-key npx motionmcp');
|
|
112
|
-
logger.info(' Command line arg: npx motionmcp --api-key=your-key');
|
|
113
|
-
logger.info(' Config file: echo \'{"apiKey": "your-key"}\' > ~/.motionmcp.json');
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
logger.info('Motion API key configured successfully');
|
|
118
|
-
|
|
119
|
-
const app = express();
|
|
120
|
-
const PORT = process.env.PORT || 3000;
|
|
121
|
-
|
|
122
|
-
app.use(cors());
|
|
123
|
-
app.use(express.json());
|
|
124
|
-
|
|
125
|
-
// Add API key to request context
|
|
126
|
-
app.use((req, res, next) => {
|
|
127
|
-
req.motionApiKey = process.env.MOTION_API_KEY;
|
|
128
|
-
next();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
app.use((req, res, next) => {
|
|
132
|
-
logger.info(`${req.method} ${req.path}`, { ip: req.ip });
|
|
133
|
-
next();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
app.get('/health', (req, res) => {
|
|
137
|
-
res.json({
|
|
138
|
-
status: 'ok',
|
|
139
|
-
timestamp: new Date().toISOString(),
|
|
140
|
-
hasApiKey: !!process.env.MOTION_API_KEY
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
app.use('/api/motion', motionRoutes);
|
|
145
|
-
|
|
146
|
-
app.use((err, req, res, next) => {
|
|
147
|
-
logger.error('Unhandled error:', err);
|
|
148
|
-
res.status(500).json({ error: 'Internal server error' });
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
app.listen(PORT, () => {
|
|
152
|
-
logger.info(`Motion MCP Server running on port ${PORT}`);
|
|
153
|
-
logger.info(`Health check available at http://localhost:${PORT}/health`);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
return app;
|
|
157
|
-
} catch (error) {
|
|
158
|
-
logger.error('Failed to start server:', error);
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Handle graceful shutdown
|
|
164
|
-
process.on('SIGINT', () => {
|
|
165
|
-
logger.info('Received SIGINT, shutting down gracefully');
|
|
166
|
-
process.exit(0);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
process.on('SIGTERM', () => {
|
|
170
|
-
logger.info('Received SIGTERM, shutting down gracefully');
|
|
171
|
-
process.exit(0);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Start the server if this file is run directly
|
|
175
|
-
if (require.main === module) {
|
|
176
|
-
startServer().catch(console.error);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
module.exports = { startServer };
|