@apify/mcpc 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 +36 -0
- package/.eslintrc.json +44 -0
- package/.idea/codeStyles/Project.xml +60 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +11 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +572 -0
- package/LICENSE +201 -0
- package/PHASE1-SUMMARY.md +269 -0
- package/PUBLISHING.md +111 -0
- package/README.md +1056 -0
- package/TESTING.md +212 -0
- package/TODOs.md +94 -0
- package/bin/mcpc +9 -0
- package/bin/mcpc-bridge +9 -0
- package/dist/bridge/index.d.ts +3 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +587 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +9 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +81 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/clean.d.ts +11 -0
- package/dist/cli/commands/clean.d.ts.map +1 -0
- package/dist/cli/commands/clean.js +224 -0
- package/dist/cli/commands/clean.js.map +1 -0
- package/dist/cli/commands/index.d.ts +8 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +8 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/logging.d.ts +3 -0
- package/dist/cli/commands/logging.d.ts.map +1 -0
- package/dist/cli/commands/logging.js +22 -0
- package/dist/cli/commands/logging.js.map +1 -0
- package/dist/cli/commands/prompts.d.ts +6 -0
- package/dist/cli/commands/prompts.d.ts.map +1 -0
- package/dist/cli/commands/prompts.js +27 -0
- package/dist/cli/commands/prompts.js.map +1 -0
- package/dist/cli/commands/resources.d.ts +11 -0
- package/dist/cli/commands/resources.d.ts.map +1 -0
- package/dist/cli/commands/resources.js +70 -0
- package/dist/cli/commands/resources.js.map +1 -0
- package/dist/cli/commands/sessions.d.ts +28 -0
- package/dist/cli/commands/sessions.d.ts.map +1 -0
- package/dist/cli/commands/sessions.js +356 -0
- package/dist/cli/commands/sessions.js.map +1 -0
- package/dist/cli/commands/tools.d.ts +8 -0
- package/dist/cli/commands/tools.d.ts.map +1 -0
- package/dist/cli/commands/tools.js +54 -0
- package/dist/cli/commands/tools.js.map +1 -0
- package/dist/cli/commands/utilities.d.ts +3 -0
- package/dist/cli/commands/utilities.d.ts.map +1 -0
- package/dist/cli/commands/utilities.js +20 -0
- package/dist/cli/commands/utilities.js.map +1 -0
- package/dist/cli/helpers.d.ts +18 -0
- package/dist/cli/helpers.d.ts.map +1 -0
- package/dist/cli/helpers.js +165 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +326 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +18 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +221 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parser.d.ts +19 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +168 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/shell-parser.d.ts +5 -0
- package/dist/cli/shell-parser.d.ts.map +1 -0
- package/dist/cli/shell-parser.js +38 -0
- package/dist/cli/shell-parser.js.map +1 -0
- package/dist/cli/shell.d.ts +2 -0
- package/dist/cli/shell.d.ts.map +1 -0
- package/dist/cli/shell.js +277 -0
- package/dist/cli/shell.js.map +1 -0
- package/dist/cli/tool-result.d.ts +2 -0
- package/dist/cli/tool-result.d.ts.map +1 -0
- package/dist/cli/tool-result.js +19 -0
- package/dist/cli/tool-result.js.map +1 -0
- package/dist/core/factory.d.ts +19 -0
- package/dist/core/factory.d.ts.map +1 -0
- package/dist/core/factory.js +55 -0
- package/dist/core/factory.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/mcp-client.d.ts +30 -0
- package/dist/core/mcp-client.d.ts.map +1 -0
- package/dist/core/mcp-client.js +215 -0
- package/dist/core/mcp-client.js.map +1 -0
- package/dist/core/transports.d.ts +12 -0
- package/dist/core/transports.d.ts.map +1 -0
- package/dist/core/transports.js +65 -0
- package/dist/core/transports.js.map +1 -0
- package/dist/lib/auth/auth-profiles.d.ts +7 -0
- package/dist/lib/auth/auth-profiles.d.ts.map +1 -0
- package/dist/lib/auth/auth-profiles.js +105 -0
- package/dist/lib/auth/auth-profiles.js.map +1 -0
- package/dist/lib/auth/keychain.d.ts +22 -0
- package/dist/lib/auth/keychain.d.ts.map +1 -0
- package/dist/lib/auth/keychain.js +92 -0
- package/dist/lib/auth/keychain.js.map +1 -0
- package/dist/lib/auth/oauth-flow.d.ts +7 -0
- package/dist/lib/auth/oauth-flow.d.ts.map +1 -0
- package/dist/lib/auth/oauth-flow.js +236 -0
- package/dist/lib/auth/oauth-flow.js.map +1 -0
- package/dist/lib/auth/oauth-provider.d.ts +24 -0
- package/dist/lib/auth/oauth-provider.d.ts.map +1 -0
- package/dist/lib/auth/oauth-provider.js +144 -0
- package/dist/lib/auth/oauth-provider.js.map +1 -0
- package/dist/lib/auth/oauth-token-manager.d.ts +25 -0
- package/dist/lib/auth/oauth-token-manager.d.ts.map +1 -0
- package/dist/lib/auth/oauth-token-manager.js +70 -0
- package/dist/lib/auth/oauth-token-manager.js.map +1 -0
- package/dist/lib/auth/oauth-utils.d.ts +14 -0
- package/dist/lib/auth/oauth-utils.d.ts.map +1 -0
- package/dist/lib/auth/oauth-utils.js +68 -0
- package/dist/lib/auth/oauth-utils.js.map +1 -0
- package/dist/lib/auth/token-refresh.d.ts +2 -0
- package/dist/lib/auth/token-refresh.d.ts.map +1 -0
- package/dist/lib/auth/token-refresh.js +70 -0
- package/dist/lib/auth/token-refresh.js.map +1 -0
- package/dist/lib/bridge-client.d.ts +23 -0
- package/dist/lib/bridge-client.d.ts.map +1 -0
- package/dist/lib/bridge-client.js +181 -0
- package/dist/lib/bridge-client.js.map +1 -0
- package/dist/lib/bridge-manager.d.ts +17 -0
- package/dist/lib/bridge-manager.d.ts.map +1 -0
- package/dist/lib/bridge-manager.js +240 -0
- package/dist/lib/bridge-manager.js.map +1 -0
- package/dist/lib/config.d.ts +6 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +116 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +23 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +81 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/file-lock.d.ts +2 -0
- package/dist/lib/file-lock.d.ts.map +1 -0
- package/dist/lib/file-lock.js +46 -0
- package/dist/lib/file-lock.js.map +1 -0
- package/dist/lib/file-logger.d.ts +19 -0
- package/dist/lib/file-logger.d.ts.map +1 -0
- package/dist/lib/file-logger.js +126 -0
- package/dist/lib/file-logger.js.map +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/logger.d.ts +24 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +189 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/session-client.d.ts +28 -0
- package/dist/lib/session-client.d.ts.map +1 -0
- package/dist/lib/session-client.js +104 -0
- package/dist/lib/session-client.js.map +1 -0
- package/dist/lib/sessions.d.ts +9 -0
- package/dist/lib/sessions.d.ts.map +1 -0
- package/dist/lib/sessions.js +116 -0
- package/dist/lib/sessions.js.map +1 -0
- package/dist/lib/types.d.ts +117 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +29 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +173 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +71 -0
- package/tsconfig.test.json +11 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createMcpClient } from '../core/factory.js';
|
|
2
|
+
import { ClientError, NetworkError, AuthError } from '../lib/errors.js';
|
|
3
|
+
import { normalizeServerUrl, isValidSessionName } from '../lib/utils.js';
|
|
4
|
+
import { setVerbose, createLogger } from '../lib/logger.js';
|
|
5
|
+
import { loadConfig, getServerConfig, validateServerConfig } from '../lib/config.js';
|
|
6
|
+
import { getValidAccessTokenFromKeychain } from '../lib/auth/token-refresh.js';
|
|
7
|
+
import { logTarget } from './output.js';
|
|
8
|
+
import packageJson from '../../package.json' with { type: 'json' };
|
|
9
|
+
import { DEFAULT_AUTH_PROFILE } from '../lib/auth/oauth-utils.js';
|
|
10
|
+
const logger = createLogger('cli');
|
|
11
|
+
function parseHeaderFlags(headerFlags) {
|
|
12
|
+
const headers = {};
|
|
13
|
+
if (headerFlags) {
|
|
14
|
+
for (const header of headerFlags) {
|
|
15
|
+
const colonIndex = header.indexOf(':');
|
|
16
|
+
if (colonIndex < 1) {
|
|
17
|
+
throw new ClientError(`Invalid header format: ${header}. Use "Key: Value"`);
|
|
18
|
+
}
|
|
19
|
+
const key = header.substring(0, colonIndex).trim();
|
|
20
|
+
const value = header.substring(colonIndex + 1).trim();
|
|
21
|
+
headers[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return headers;
|
|
25
|
+
}
|
|
26
|
+
async function addAuthHeader(url, headers, profileName = DEFAULT_AUTH_PROFILE) {
|
|
27
|
+
try {
|
|
28
|
+
const accessToken = await getValidAccessTokenFromKeychain(url, profileName);
|
|
29
|
+
if (!accessToken) {
|
|
30
|
+
return headers;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...headers,
|
|
34
|
+
Authorization: `Bearer ${accessToken}`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof AuthError) {
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
logger.warn(`Failed to load auth profile: ${error.message}`);
|
|
42
|
+
return headers;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function resolveTarget(target, options = {}) {
|
|
46
|
+
if (options.verbose) {
|
|
47
|
+
setVerbose(true);
|
|
48
|
+
}
|
|
49
|
+
if (isValidSessionName(target)) {
|
|
50
|
+
throw new ClientError(`Session target should be handled by withMcpClient: ${target}`);
|
|
51
|
+
}
|
|
52
|
+
if (options.config) {
|
|
53
|
+
logger.debug(`Loading config file: ${options.config}`);
|
|
54
|
+
const config = loadConfig(options.config);
|
|
55
|
+
const serverConfig = getServerConfig(config, target);
|
|
56
|
+
validateServerConfig(serverConfig);
|
|
57
|
+
if (serverConfig.url) {
|
|
58
|
+
const headers = {
|
|
59
|
+
...serverConfig.headers,
|
|
60
|
+
...parseHeaderFlags(options.headers),
|
|
61
|
+
};
|
|
62
|
+
const headersWithAuth = await addAuthHeader(serverConfig.url, headers, options.profile);
|
|
63
|
+
const transportConfig = {
|
|
64
|
+
type: 'http',
|
|
65
|
+
url: serverConfig.url,
|
|
66
|
+
headers: headersWithAuth,
|
|
67
|
+
};
|
|
68
|
+
if (options.timeout) {
|
|
69
|
+
transportConfig.timeoutMs = options.timeout * 1000;
|
|
70
|
+
}
|
|
71
|
+
else if (serverConfig.timeout) {
|
|
72
|
+
transportConfig.timeoutMs = serverConfig.timeout * 1000;
|
|
73
|
+
}
|
|
74
|
+
return transportConfig;
|
|
75
|
+
}
|
|
76
|
+
else if (serverConfig.command) {
|
|
77
|
+
const transportConfig = {
|
|
78
|
+
type: 'stdio',
|
|
79
|
+
command: serverConfig.command,
|
|
80
|
+
};
|
|
81
|
+
if (serverConfig.args !== undefined) {
|
|
82
|
+
transportConfig.args = serverConfig.args;
|
|
83
|
+
}
|
|
84
|
+
if (serverConfig.env !== undefined) {
|
|
85
|
+
transportConfig.env = serverConfig.env;
|
|
86
|
+
}
|
|
87
|
+
return transportConfig;
|
|
88
|
+
}
|
|
89
|
+
throw new ClientError(`Invalid server configuration for: ${target}`);
|
|
90
|
+
}
|
|
91
|
+
let url;
|
|
92
|
+
try {
|
|
93
|
+
url = normalizeServerUrl(target);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
throw new ClientError(`Failed to resolve target: ${target}\n` +
|
|
97
|
+
`Target must be one of:\n` +
|
|
98
|
+
` - Named session (@name)\n` +
|
|
99
|
+
` - Server URL (e.g., mcp.apify.com or https://mcp.apify.com)\n` +
|
|
100
|
+
` - Entry in JSON config file specified by --config flag\n\n` +
|
|
101
|
+
`Error: ${error.message}`);
|
|
102
|
+
}
|
|
103
|
+
const headers = parseHeaderFlags(options.headers);
|
|
104
|
+
const headersWithAuth = await addAuthHeader(url, headers, options.profile);
|
|
105
|
+
const config = {
|
|
106
|
+
type: 'http',
|
|
107
|
+
url,
|
|
108
|
+
headers: headersWithAuth,
|
|
109
|
+
};
|
|
110
|
+
if (options.timeout) {
|
|
111
|
+
config.timeoutMs = options.timeout * 1000;
|
|
112
|
+
}
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
export async function withMcpClient(target, options, callback) {
|
|
116
|
+
if (isValidSessionName(target)) {
|
|
117
|
+
const { withSessionClient } = await import('../lib/session-client.js');
|
|
118
|
+
logger.debug('Using session:', target);
|
|
119
|
+
if (options.outputMode) {
|
|
120
|
+
logTarget(target, options.outputMode, options.hideTarget);
|
|
121
|
+
}
|
|
122
|
+
return await withSessionClient(target, callback);
|
|
123
|
+
}
|
|
124
|
+
const transportConfig = await resolveTarget(target, options);
|
|
125
|
+
logger.debug('Resolved target:', { target, transportConfig });
|
|
126
|
+
const clientConfig = {
|
|
127
|
+
clientInfo: { name: 'mcpc', version: packageJson.version },
|
|
128
|
+
transport: transportConfig,
|
|
129
|
+
capabilities: {
|
|
130
|
+
roots: { listChanged: true },
|
|
131
|
+
sampling: {},
|
|
132
|
+
},
|
|
133
|
+
autoConnect: true,
|
|
134
|
+
};
|
|
135
|
+
if (options.verbose) {
|
|
136
|
+
clientConfig.verbose = true;
|
|
137
|
+
}
|
|
138
|
+
const client = await createMcpClient(clientConfig);
|
|
139
|
+
try {
|
|
140
|
+
logger.debug('Connected successfully');
|
|
141
|
+
if (options.outputMode) {
|
|
142
|
+
logTarget(target, options.outputMode, options.hideTarget);
|
|
143
|
+
}
|
|
144
|
+
const result = await callback(client);
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
logger.error('MCP operation failed:', error);
|
|
149
|
+
if (error instanceof NetworkError || error instanceof ClientError) {
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
throw new NetworkError(`Failed to communicate with MCP server: ${error.message}`, { originalError: error });
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
try {
|
|
156
|
+
logger.debug('Closing connection...');
|
|
157
|
+
await client.close();
|
|
158
|
+
logger.debug('Connection closed');
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
logger.warn('Error closing connection:', error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAA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|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { setVerbose, closeFileLogger } from '../lib/index.js';
|
|
4
|
+
import { isMcpError, formatError } from '../lib/index.js';
|
|
5
|
+
import { formatJsonError } from './output.js';
|
|
6
|
+
import * as tools from './commands/tools.js';
|
|
7
|
+
import * as resources from './commands/resources.js';
|
|
8
|
+
import * as prompts from './commands/prompts.js';
|
|
9
|
+
import * as sessions from './commands/sessions.js';
|
|
10
|
+
import * as logging from './commands/logging.js';
|
|
11
|
+
import * as utilities from './commands/utilities.js';
|
|
12
|
+
import * as auth from './commands/auth.js';
|
|
13
|
+
import { clean } from './commands/clean.js';
|
|
14
|
+
import { findTarget, extractOptions, hasCommandAfterTarget, getVerboseFromEnv, getJsonFromEnv } from './parser.js';
|
|
15
|
+
import packageJson from '../../package.json' with { type: 'json' };
|
|
16
|
+
function getOptionsFromCommand(command) {
|
|
17
|
+
const opts = command.optsWithGlobals ? command.optsWithGlobals() : command.opts();
|
|
18
|
+
const verbose = opts.verbose || getVerboseFromEnv();
|
|
19
|
+
if (verbose)
|
|
20
|
+
setVerbose(true);
|
|
21
|
+
const json = opts.json || getJsonFromEnv();
|
|
22
|
+
const options = {
|
|
23
|
+
outputMode: (json ? 'json' : 'human'),
|
|
24
|
+
};
|
|
25
|
+
if (opts.config)
|
|
26
|
+
options.config = opts.config;
|
|
27
|
+
if (opts.header) {
|
|
28
|
+
options.headers = Array.isArray(opts.header) ? opts.header : [opts.header];
|
|
29
|
+
}
|
|
30
|
+
if (opts.timeout)
|
|
31
|
+
options.timeout = parseInt(opts.timeout, 10);
|
|
32
|
+
if (opts.profile)
|
|
33
|
+
options.profile = opts.profile;
|
|
34
|
+
if (verbose)
|
|
35
|
+
options.verbose = verbose;
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const args = process.argv.slice(2);
|
|
40
|
+
const handleExit = () => {
|
|
41
|
+
void closeFileLogger().then(() => {
|
|
42
|
+
process.exit(0);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
process.on('SIGTERM', handleExit);
|
|
46
|
+
process.on('SIGINT', handleExit);
|
|
47
|
+
process.on('exit', () => {
|
|
48
|
+
void closeFileLogger();
|
|
49
|
+
});
|
|
50
|
+
if (args.includes('--help') ||
|
|
51
|
+
args.includes('-h') ||
|
|
52
|
+
args.includes('--version') ||
|
|
53
|
+
args.includes('-v')) {
|
|
54
|
+
const program = createProgram();
|
|
55
|
+
await program.parseAsync(process.argv);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const cleanArg = args.find((arg) => arg === '--clean' || arg.startsWith('--clean='));
|
|
59
|
+
if (cleanArg) {
|
|
60
|
+
const options = extractOptions(args);
|
|
61
|
+
if (options.verbose)
|
|
62
|
+
setVerbose(true);
|
|
63
|
+
const cleanValue = cleanArg.includes('=') ? cleanArg.split('=')[1] : '';
|
|
64
|
+
const cleanTypes = cleanValue ? cleanValue.split(',').map((s) => s.trim()) : [];
|
|
65
|
+
await clean({
|
|
66
|
+
outputMode: options.json ? 'json' : 'human',
|
|
67
|
+
sessions: cleanTypes.includes('sessions'),
|
|
68
|
+
profiles: cleanTypes.includes('profiles'),
|
|
69
|
+
logs: cleanTypes.includes('logs'),
|
|
70
|
+
all: cleanTypes.includes('all'),
|
|
71
|
+
});
|
|
72
|
+
await closeFileLogger();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const targetInfo = findTarget(args);
|
|
76
|
+
if (!targetInfo) {
|
|
77
|
+
const { json } = extractOptions(args);
|
|
78
|
+
await sessions.listSessionsAndAuthProfiles({ outputMode: json ? 'json' : 'human' });
|
|
79
|
+
if (!json) {
|
|
80
|
+
console.log('\nRun "mcpc --help" for usage information.');
|
|
81
|
+
}
|
|
82
|
+
await closeFileLogger();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { target, targetIndex } = targetInfo;
|
|
86
|
+
const modifiedArgs = [
|
|
87
|
+
...process.argv.slice(0, 2),
|
|
88
|
+
...args.slice(0, targetIndex),
|
|
89
|
+
...args.slice(targetIndex + 1),
|
|
90
|
+
];
|
|
91
|
+
try {
|
|
92
|
+
await handleCommands(target, modifiedArgs);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
await closeFileLogger();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function createProgram() {
|
|
99
|
+
const program = new Command();
|
|
100
|
+
program
|
|
101
|
+
.name('mcpc')
|
|
102
|
+
.description('Universal command-line client for the Model Context Protocol (MCP).')
|
|
103
|
+
.usage('[options] <target> [command]')
|
|
104
|
+
.version(packageJson.version, '-v, --version', 'Output the version number')
|
|
105
|
+
.helpOption('-h, --help', 'Display general help')
|
|
106
|
+
.option('-j, --json', 'Output in JSON format')
|
|
107
|
+
.option('--verbose', 'Enable verbose logging')
|
|
108
|
+
.option('-c, --config <file>', 'Path to MCP config JSON file')
|
|
109
|
+
.option('-H, --header <header>', 'Add HTTP header (can be repeated)')
|
|
110
|
+
.option('--timeout <seconds>', 'Request timeout in seconds (default: 300)')
|
|
111
|
+
.option('--profile <name>', 'Authentication profile to use (default: "default")')
|
|
112
|
+
.option('--schema <file>', 'Validate against expected tool/prompt schema')
|
|
113
|
+
.option('--schema-mode <mode>', 'Schema validation mode: strict, compatible (default), or ignore')
|
|
114
|
+
.option('--insecure', 'Disable SSL certificate validation');
|
|
115
|
+
program.addHelpText('after', `
|
|
116
|
+
Where <target> can be:
|
|
117
|
+
<url> Remote MCP server URL (e.g., mcp.apify.com)
|
|
118
|
+
<config-entry> Entry from MCP config file specified in --config
|
|
119
|
+
@<name> Named session (e.g., @apify)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Examples:
|
|
123
|
+
$ mcpc # List sessions and auth profiles
|
|
124
|
+
$ mcpc mcp.apify.com login # Login to MCP server using OAuth
|
|
125
|
+
$ mcpc mcp.apify.com tools-list # List server tools
|
|
126
|
+
$ mcpc mcp.apify.com session @apify # Create or reconnect persistent session
|
|
127
|
+
$ mcpc @apify tools-call search-actors --args query="crawler" # Call tool with arguments
|
|
128
|
+
`);
|
|
129
|
+
return program;
|
|
130
|
+
}
|
|
131
|
+
async function handleCommands(target, args) {
|
|
132
|
+
const program = createProgram();
|
|
133
|
+
program.argument('<target>', 'Target (session @name, MCP config entry, or server URL)');
|
|
134
|
+
if (!hasCommandAfterTarget(args)) {
|
|
135
|
+
const options = extractOptions(args);
|
|
136
|
+
if (options.verbose)
|
|
137
|
+
setVerbose(true);
|
|
138
|
+
await sessions.showServerInfo(target, {
|
|
139
|
+
outputMode: options.json ? 'json' : 'human',
|
|
140
|
+
...(options.verbose && { verbose: true }),
|
|
141
|
+
...(options.config && { config: options.config }),
|
|
142
|
+
...(options.headers && { headers: options.headers }),
|
|
143
|
+
...(options.timeout !== undefined && { timeout: options.timeout }),
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
program
|
|
148
|
+
.command('help')
|
|
149
|
+
.description('Show server instructions and available capabilities')
|
|
150
|
+
.action(async (_options, command) => {
|
|
151
|
+
await sessions.showHelp(target, getOptionsFromCommand(command));
|
|
152
|
+
});
|
|
153
|
+
program
|
|
154
|
+
.command('shell')
|
|
155
|
+
.description('Interactive shell for the target')
|
|
156
|
+
.action(async () => {
|
|
157
|
+
await sessions.openShell(target);
|
|
158
|
+
});
|
|
159
|
+
program
|
|
160
|
+
.command('close')
|
|
161
|
+
.description('Close the session')
|
|
162
|
+
.action(async (_options, command) => {
|
|
163
|
+
await sessions.closeSession(target, getOptionsFromCommand(command));
|
|
164
|
+
});
|
|
165
|
+
program
|
|
166
|
+
.command('session <name>')
|
|
167
|
+
.description('Create or reconnect a session to an MCP server')
|
|
168
|
+
.action(async (name, _options, command) => {
|
|
169
|
+
await sessions.connectSession(name, target, getOptionsFromCommand(command));
|
|
170
|
+
});
|
|
171
|
+
program
|
|
172
|
+
.command('login')
|
|
173
|
+
.description('Login to a server using OAuth and save authentication profile')
|
|
174
|
+
.option('--profile <name>', 'Profile name (default: default)')
|
|
175
|
+
.option('--scope <scope>', 'OAuth scope(s) to request')
|
|
176
|
+
.action(async (options, command) => {
|
|
177
|
+
await auth.login(target, {
|
|
178
|
+
profile: options.profile,
|
|
179
|
+
scope: options.scope,
|
|
180
|
+
...getOptionsFromCommand(command),
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
program
|
|
184
|
+
.command('logout')
|
|
185
|
+
.description('Delete an authentication profile')
|
|
186
|
+
.option('--profile <name>', 'Profile name (default: default)')
|
|
187
|
+
.action(async (options, command) => {
|
|
188
|
+
await auth.logout(target, {
|
|
189
|
+
profile: options.profile,
|
|
190
|
+
...getOptionsFromCommand(command),
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
program
|
|
194
|
+
.command('tools')
|
|
195
|
+
.description('List available tools (shorthand for tools-list)')
|
|
196
|
+
.action(async (_options, command) => {
|
|
197
|
+
await tools.listTools(target, getOptionsFromCommand(command));
|
|
198
|
+
});
|
|
199
|
+
program
|
|
200
|
+
.command('tools-list')
|
|
201
|
+
.description('List available tools')
|
|
202
|
+
.action(async (_options, command) => {
|
|
203
|
+
await tools.listTools(target, getOptionsFromCommand(command));
|
|
204
|
+
});
|
|
205
|
+
program
|
|
206
|
+
.command('tools-schema <name>')
|
|
207
|
+
.description('Get information about a specific tool')
|
|
208
|
+
.action(async (name, _options, command) => {
|
|
209
|
+
await tools.getTool(target, name, getOptionsFromCommand(command));
|
|
210
|
+
});
|
|
211
|
+
program
|
|
212
|
+
.command('tools-call <name>')
|
|
213
|
+
.description('Call a tool with arguments')
|
|
214
|
+
.option('--args [pairs...]', 'Tool arguments as key=val or key:=json pairs')
|
|
215
|
+
.option('--args-file <file>', 'Load arguments from JSON file')
|
|
216
|
+
.action(async (name, options, command) => {
|
|
217
|
+
await tools.callTool(target, name, {
|
|
218
|
+
args: options.args,
|
|
219
|
+
argsFile: options.argsFile,
|
|
220
|
+
...getOptionsFromCommand(command),
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
program
|
|
224
|
+
.command('resources')
|
|
225
|
+
.description('List available resources (shorthand for resources-list)')
|
|
226
|
+
.action(async (_options, command) => {
|
|
227
|
+
await resources.listResources(target, getOptionsFromCommand(command));
|
|
228
|
+
});
|
|
229
|
+
program
|
|
230
|
+
.command('resources-list')
|
|
231
|
+
.description('List available resources')
|
|
232
|
+
.action(async (_options, command) => {
|
|
233
|
+
await resources.listResources(target, getOptionsFromCommand(command));
|
|
234
|
+
});
|
|
235
|
+
program
|
|
236
|
+
.command('resources-read <uri>')
|
|
237
|
+
.description('Get a resource by URI')
|
|
238
|
+
.option('-o, --output <file>', 'Write resource to file')
|
|
239
|
+
.option('--max-size <bytes>', 'Maximum resource size in bytes')
|
|
240
|
+
.action(async (uri, options, command) => {
|
|
241
|
+
await resources.getResource(target, uri, {
|
|
242
|
+
output: options.output,
|
|
243
|
+
raw: options.raw,
|
|
244
|
+
maxSize: options.maxSize,
|
|
245
|
+
...getOptionsFromCommand(command),
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
program
|
|
249
|
+
.command('resources-subscribe <uri>')
|
|
250
|
+
.description('Subscribe to resource updates')
|
|
251
|
+
.action(async (uri, _options, command) => {
|
|
252
|
+
await resources.subscribeResource(target, uri, getOptionsFromCommand(command));
|
|
253
|
+
});
|
|
254
|
+
program
|
|
255
|
+
.command('resources-unsubscribe <uri>')
|
|
256
|
+
.description('Unsubscribe from resource updates')
|
|
257
|
+
.action(async (uri, _options, command) => {
|
|
258
|
+
await resources.unsubscribeResource(target, uri, getOptionsFromCommand(command));
|
|
259
|
+
});
|
|
260
|
+
program
|
|
261
|
+
.command('resources-templates-list')
|
|
262
|
+
.description('List available resource templates')
|
|
263
|
+
.action(async (_options, command) => {
|
|
264
|
+
await resources.listResourceTemplates(target, getOptionsFromCommand(command));
|
|
265
|
+
});
|
|
266
|
+
program
|
|
267
|
+
.command('prompts')
|
|
268
|
+
.description('List available prompts (shorthand for prompts-list)')
|
|
269
|
+
.action(async (_options, command) => {
|
|
270
|
+
await prompts.listPrompts(target, getOptionsFromCommand(command));
|
|
271
|
+
});
|
|
272
|
+
program
|
|
273
|
+
.command('prompts-list')
|
|
274
|
+
.description('List available prompts')
|
|
275
|
+
.action(async (_options, command) => {
|
|
276
|
+
await prompts.listPrompts(target, getOptionsFromCommand(command));
|
|
277
|
+
});
|
|
278
|
+
program
|
|
279
|
+
.command('prompts-get <name>')
|
|
280
|
+
.description('Get a prompt by name')
|
|
281
|
+
.option('--args [pairs...]', 'Prompt arguments as key=val or key:=json pairs')
|
|
282
|
+
.action(async (name, options, command) => {
|
|
283
|
+
await prompts.getPrompt(target, name, {
|
|
284
|
+
args: options.args,
|
|
285
|
+
...getOptionsFromCommand(command),
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
program
|
|
289
|
+
.command('logging-set-level <level>')
|
|
290
|
+
.description('Set server logging level (debug, info, notice, warning, error, critical, alert, emergency)')
|
|
291
|
+
.action(async (level, _options, command) => {
|
|
292
|
+
await logging.setLogLevel(target, level, getOptionsFromCommand(command));
|
|
293
|
+
});
|
|
294
|
+
program
|
|
295
|
+
.command('ping')
|
|
296
|
+
.description('Ping the MCP server to check if it is alive')
|
|
297
|
+
.action(async (_options, command) => {
|
|
298
|
+
await utilities.ping(target, getOptionsFromCommand(command));
|
|
299
|
+
});
|
|
300
|
+
try {
|
|
301
|
+
await program.parseAsync(args);
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
const opts = program.opts();
|
|
305
|
+
const outputMode = opts.json ? 'json' : 'human';
|
|
306
|
+
if (isMcpError(error)) {
|
|
307
|
+
if (outputMode === 'json') {
|
|
308
|
+
console.error(formatJsonError(error, error.code));
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
console.error(formatError(error, opts.verbose));
|
|
312
|
+
}
|
|
313
|
+
process.exit(error.code);
|
|
314
|
+
}
|
|
315
|
+
console.error(outputMode === 'json'
|
|
316
|
+
? formatJsonError(error, 1)
|
|
317
|
+
: formatError(error, opts.verbose));
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
main().catch(async (error) => {
|
|
322
|
+
console.error('Fatal error:', error);
|
|
323
|
+
await closeFileLogger();
|
|
324
|
+
process.exit(1);
|
|
325
|
+
});
|
|
326
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAmBnE,SAAS,qBAAqB,CAAC,OAAgB;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC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KAAc,EAAE,CAAC,CAAC;YACpC,CAAC,CAAC,WAAW,CAAC,KAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAC9C,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAGD,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,eAAe,EAAE,CAAC;IACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OutputMode } from '../lib/index.js';
|
|
2
|
+
import type { Tool, Resource, Prompt } from '../lib/types.js';
|
|
3
|
+
export { extractSingleTextContent } from './tool-result.js';
|
|
4
|
+
export declare function formatOutput(data: unknown, mode?: OutputMode): string;
|
|
5
|
+
export declare function formatJson(data: unknown): string;
|
|
6
|
+
export declare function formatHuman(data: unknown): string;
|
|
7
|
+
export declare function formatTools(tools: Tool[]): string;
|
|
8
|
+
export declare function formatToolDetail(tool: Tool): string;
|
|
9
|
+
export declare function formatResources(resources: Resource[]): string;
|
|
10
|
+
export declare function formatPrompts(prompts: Prompt[]): string;
|
|
11
|
+
export declare function formatObject(obj: Record<string, unknown>): string;
|
|
12
|
+
export declare function formatSuccess(message: string): string;
|
|
13
|
+
export declare function formatError(message: string): string;
|
|
14
|
+
export declare function formatWarning(message: string): string;
|
|
15
|
+
export declare function formatInfo(message: string): string;
|
|
16
|
+
export declare function logTarget(target: string, outputMode: OutputMode, hide?: boolean): void;
|
|
17
|
+
export declare function formatJsonError(error: Error, code: number): string;
|
|
18
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAQA,OA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