@apify/mcpc 0.1.4 → 0.1.6

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.
Files changed (90) hide show
  1. package/.claude/settings.local.json +31 -1
  2. package/.idea/codeStyles/Project.xml +4 -1
  3. package/.idea/workspace.xml +308 -276
  4. package/README.md +666 -521
  5. package/dist/bridge/index.js +78 -3
  6. package/dist/bridge/index.js.map +1 -1
  7. package/dist/bridge/proxy-server.d.ts +22 -0
  8. package/dist/bridge/proxy-server.d.ts.map +1 -0
  9. package/dist/bridge/proxy-server.js +161 -0
  10. package/dist/bridge/proxy-server.js.map +1 -0
  11. package/dist/cli/commands/clean.js +8 -8
  12. package/dist/cli/commands/clean.js.map +1 -1
  13. package/dist/cli/commands/logging.js +1 -1
  14. package/dist/cli/commands/logging.js.map +1 -1
  15. package/dist/cli/commands/prompts.d.ts.map +1 -1
  16. package/dist/cli/commands/prompts.js +13 -4
  17. package/dist/cli/commands/prompts.js.map +1 -1
  18. package/dist/cli/commands/resources.js +5 -5
  19. package/dist/cli/commands/resources.js.map +1 -1
  20. package/dist/cli/commands/sessions.d.ts +2 -0
  21. package/dist/cli/commands/sessions.d.ts.map +1 -1
  22. package/dist/cli/commands/sessions.js +68 -57
  23. package/dist/cli/commands/sessions.js.map +1 -1
  24. package/dist/cli/commands/tools.d.ts +0 -1
  25. package/dist/cli/commands/tools.d.ts.map +1 -1
  26. package/dist/cli/commands/tools.js +9 -9
  27. package/dist/cli/commands/tools.js.map +1 -1
  28. package/dist/cli/commands/utilities.js +1 -1
  29. package/dist/cli/commands/utilities.js.map +1 -1
  30. package/dist/cli/helpers.d.ts +7 -2
  31. package/dist/cli/helpers.d.ts.map +1 -1
  32. package/dist/cli/helpers.js +31 -14
  33. package/dist/cli/helpers.js.map +1 -1
  34. package/dist/cli/index.js +75 -45
  35. package/dist/cli/index.js.map +1 -1
  36. package/dist/cli/output.d.ts.map +1 -1
  37. package/dist/cli/output.js +87 -5
  38. package/dist/cli/output.js.map +1 -1
  39. package/dist/cli/parser.d.ts +6 -1
  40. package/dist/cli/parser.d.ts.map +1 -1
  41. package/dist/cli/parser.js +78 -53
  42. package/dist/cli/parser.js.map +1 -1
  43. package/dist/cli/shell.d.ts.map +1 -1
  44. package/dist/cli/shell.js +27 -13
  45. package/dist/cli/shell.js.map +1 -1
  46. package/dist/core/factory.d.ts.map +1 -1
  47. package/dist/core/factory.js +1 -0
  48. package/dist/core/factory.js.map +1 -1
  49. package/dist/core/mcp-client.d.ts +5 -0
  50. package/dist/core/mcp-client.d.ts.map +1 -1
  51. package/dist/core/mcp-client.js +76 -26
  52. package/dist/core/mcp-client.js.map +1 -1
  53. package/dist/lib/auth/keychain.d.ts +3 -0
  54. package/dist/lib/auth/keychain.d.ts.map +1 -1
  55. package/dist/lib/auth/keychain.js +18 -0
  56. package/dist/lib/auth/keychain.js.map +1 -1
  57. package/dist/lib/auth/oauth-flow.d.ts.map +1 -1
  58. package/dist/lib/auth/oauth-flow.js +52 -12
  59. package/dist/lib/auth/oauth-flow.js.map +1 -1
  60. package/dist/lib/bridge-manager.d.ts +2 -1
  61. package/dist/lib/bridge-manager.d.ts.map +1 -1
  62. package/dist/lib/bridge-manager.js +25 -6
  63. package/dist/lib/bridge-manager.js.map +1 -1
  64. package/dist/lib/errors.d.ts +6 -1
  65. package/dist/lib/errors.d.ts.map +1 -1
  66. package/dist/lib/errors.js +13 -1
  67. package/dist/lib/errors.js.map +1 -1
  68. package/dist/lib/logger.d.ts +2 -0
  69. package/dist/lib/logger.d.ts.map +1 -1
  70. package/dist/lib/logger.js +10 -0
  71. package/dist/lib/logger.js.map +1 -1
  72. package/dist/lib/schema-validator.d.ts.map +1 -1
  73. package/dist/lib/schema-validator.js +45 -0
  74. package/dist/lib/schema-validator.js.map +1 -1
  75. package/dist/lib/sessions.d.ts +1 -1
  76. package/dist/lib/sessions.d.ts.map +1 -1
  77. package/dist/lib/sessions.js +31 -10
  78. package/dist/lib/sessions.js.map +1 -1
  79. package/dist/lib/types.d.ts +18 -1
  80. package/dist/lib/types.d.ts.map +1 -1
  81. package/dist/lib/utils.d.ts.map +1 -1
  82. package/dist/lib/utils.js +5 -1
  83. package/dist/lib/utils.js.map +1 -1
  84. package/docs/README.md +19 -0
  85. package/docs/TODOs.md +40 -0
  86. package/docs/claude-skill/SKILL.md +53 -28
  87. package/docs/images/mcpc-screenshot.png +0 -0
  88. package/package.json +4 -3
  89. package/PUBLISHING.md +0 -111
  90. package/TODOs.md +0 -46
package/docs/TODOs.md ADDED
@@ -0,0 +1,40 @@
1
+
2
+ # TODOs
3
+
4
+
5
+ - `--capabilities '{"tools":...,"prompts":...}"` to limit access to selected MCP features and tools,
6
+ for both proxy and normal session, for simplicity.
7
+ - Implement resources-subscribe/resources-unsubscribe, --o file command properly, --max-size
8
+ automatically update the -o file on changes, without it just keep track of changed files in
9
+ bridge process' cache, and report in resources-list/resources-read operation
10
+ - Store last time of all listChanged notifications on session object, so that users can see it and act on that.
11
+
12
+ - Ensure "logging-set-level" works well
13
+
14
+ ## Later
15
+
16
+ - nit: in "login", make profile color consistent with "mcpc"
17
+ - nit: show also header / open auth statuses for HTTP servers?
18
+ - ux: consider forking "alive" session state to "alive" and "diconnected", to indicate the remove server is not responding but bridge
19
+ runs fine. We can use lastSeenAt + ping interval info for that, or status of last ping.
20
+ - perf: make the libsecret dependency soft - only load it when using keychain, but skip for auth-less (AI sandbox) use
21
+ - ux: Be even more forgiving with `args:=x`, when we know from tools/prompt schema the text is compatible with `x` even if the exact type is not -
22
+ just re-type it dynamically to make it work.
23
+ - nit: Cooler OAuth flow finish web page with CSS animation, add Apify example there, show mcpc info. E.g. next step - check Apify rather than close
24
+ - security: For auth profiles, fetch the detailed user info via http, save to profiles.json and show in 'mcpc', ensure the info is up-to-date
25
+ - later: Add unique Session.id and Profile.id and use it for OS keychain keys, to truly enable using multiple independent mcpc profiles. Use cry
26
+ - nit: Implement typing completions (e.g. "mcpc @ap...") - not sure if that's even possible
27
+ - later: maybe add --no-color option to disable chalk
28
+
29
+ ## E2E test scenarios
30
+
31
+ - On "npm run release", make the two skippable OAuth e2e tests mandatory
32
+
33
+ - Test auth profiles work long-term and sessions too - basically when running some tests the
34
+ next day they should use old saved auths and sessions.
35
+ We could have some special dir for long-term testing...
36
+
37
+
38
+ # Questions
39
+
40
+ - mcpc mcp.apify.com shell --- do we also open "virtual" session, how does it work exactly? Let's explain this in README.
@@ -22,7 +22,7 @@ mcpc @<session>
22
22
  # Tools
23
23
  mcpc <target> tools-list
24
24
  mcpc <target> tools-get <tool-name>
25
- mcpc <target> tools-call <tool-name> --args '{"key":"value"}'
25
+ mcpc <target> tools-call <tool-name> key:=value key2:="string value"
26
26
 
27
27
  # Resources
28
28
  mcpc <target> resources-list
@@ -30,10 +30,10 @@ mcpc <target> resources-read <uri>
30
30
 
31
31
  # Prompts
32
32
  mcpc <target> prompts-list
33
- mcpc <target> prompts-get <prompt-name> --args key=value
33
+ mcpc <target> prompts-get <prompt-name> arg1:=value1
34
34
 
35
35
  # Sessions (persistent connections)
36
- mcpc <server> session @<name>
36
+ mcpc <server> connect @<name>
37
37
  mcpc @<name> <command>
38
38
  mcpc @<name> close
39
39
 
@@ -44,34 +44,32 @@ mcpc <server> logout
44
44
 
45
45
  ## Target types
46
46
 
47
- - `mcp.example.com` - Direct HTTP connection to remote server
47
+ - `mcp.example.com` - Direct HTTPS connection to remote server
48
+ - `localhost:8080` or `127.0.0.1:8080` - Local HTTP server (http:// is default for localhost)
48
49
  - `@session-name` - Named persistent session (faster, maintains state)
49
50
  - `config-entry` - Entry from config file (with `--config`)
50
51
 
51
52
  ## Passing arguments
52
53
 
53
- **Inline JSON** (recommended for complex data):
54
- ```bash
55
- mcpc @s tools-call search --args '{"query":"hello","limit":10}'
56
- ```
54
+ Arguments use `key:=value` syntax. Values are auto-parsed as JSON when valid:
57
55
 
58
- **Key=value pairs** (strings):
59
56
  ```bash
60
- mcpc @s tools-call search --args query="hello world" filter=active
61
- ```
57
+ # String values
58
+ mcpc @s tools-call search query:="hello world"
62
59
 
63
- **Key:=json pairs** (typed values):
64
- ```bash
65
- mcpc @s tools-call search --args query="hello" limit:=10 enabled:=true
66
- ```
60
+ # Numbers, booleans, null (auto-parsed as JSON)
61
+ mcpc @s tools-call search query:="hello" limit:=10 enabled:=true
67
62
 
68
- **From file**:
69
- ```bash
70
- mcpc @s tools-call search --args-file params.json
71
- ```
63
+ # Complex JSON values
64
+ mcpc @s tools-call search config:='{"nested":"value"}' items:='[1,2,3]'
72
65
 
73
- **From stdin** (auto-detected when piped):
74
- ```bash
66
+ # Force string type with JSON quotes
67
+ mcpc @s tools-call search id:='"123"'
68
+
69
+ # Inline JSON object (if first arg starts with { or [)
70
+ mcpc @s tools-call search '{"query":"hello","limit":10}'
71
+
72
+ # From stdin (auto-detected when piped)
75
73
  echo '{"query":"hello"}' | mcpc @s tools-call search
76
74
  ```
77
75
 
@@ -84,7 +82,7 @@ Always use `--json` flag for machine-readable output:
84
82
  mcpc --json @apify tools-list
85
83
 
86
84
  # Call tool and parse result with jq
87
- mcpc --json @apify tools-call search --args query="test" | jq '.content[0].text'
85
+ mcpc --json @apify tools-call search query:="test" | jq '.content[0].text'
88
86
 
89
87
  # Chain commands
90
88
  mcpc --json @server1 tools-call get-data | mcpc @server2 tools-call process
@@ -96,28 +94,50 @@ Create sessions for repeated interactions:
96
94
 
97
95
  ```bash
98
96
  # Create session (or reconnect if exists)
99
- mcpc mcp.apify.com session @apify
97
+ mcpc mcp.apify.com connect @apify
100
98
 
101
99
  # Use session (faster - no reconnection overhead)
102
100
  mcpc @apify tools-list
103
- mcpc @apify tools-call search --args query="test"
101
+ mcpc @apify tools-call search query:="test"
102
+
103
+ # Restart session (useful after server updates)
104
+ mcpc @apify restart
104
105
 
105
106
  # Close when done
106
107
  mcpc @apify close
107
108
  ```
108
109
 
110
+ **Session states:**
111
+ - 🟢 **live** - Bridge running, server might or might not be responding
112
+ - 🟡 **crashed** - Bridge crashed; auto-restarts on next use
113
+ - 🔴 **expired** - Server rejected session; needs `close` and reconnect
114
+
109
115
  ## Authentication
110
116
 
111
117
  **OAuth (interactive login)**:
112
118
  ```bash
113
119
  mcpc mcp.apify.com login
114
- mcpc mcp.apify.com session @apify
120
+ mcpc mcp.apify.com connect @apify
115
121
  ```
116
122
 
117
123
  **Bearer token**:
118
124
  ```bash
119
125
  mcpc -H "Authorization: Bearer $TOKEN" mcp.apify.com tools-list
120
- mcpc -H "Authorization: Bearer $TOKEN" mcp.apify.com session @myserver
126
+ mcpc -H "Authorization: Bearer $TOKEN" mcp.apify.com connect @myserver
127
+ ```
128
+
129
+ ## Proxy server for AI isolation
130
+
131
+ Create a proxy MCP server that hides authentication tokens:
132
+
133
+ ```bash
134
+ # Human creates authenticated session with proxy
135
+ mcpc mcp.apify.com connect @ai-proxy --proxy 8080
136
+
137
+ # AI agent connects to proxy (no access to original tokens)
138
+ # Note: localhost defaults to http://
139
+ mcpc localhost:8080 tools-list
140
+ mcpc 127.0.0.1:8080 connect @sandboxed
121
141
  ```
122
142
 
123
143
  ## Common patterns
@@ -130,7 +150,7 @@ mcpc @s tools-get tool-name
130
150
 
131
151
  **Call tool and extract text result**:
132
152
  ```bash
133
- mcpc --json @s tools-call my-tool --args '{}' | jq -r '.content[0].text'
153
+ mcpc --json @s tools-call my-tool | jq -r '.content[0].text'
134
154
  ```
135
155
 
136
156
  **Read resource content**:
@@ -155,5 +175,10 @@ mcpc --config .vscode/mcp.json filesystem resources-list
155
175
 
156
176
  ```bash
157
177
  # Verbose output shows protocol details
158
- mcpc --verbose @s tools-call my-tool --args '{}'
178
+ mcpc --verbose @s tools-call my-tool
159
179
  ```
180
+
181
+ ## Example script
182
+
183
+ See [`docs/examples/company-lookup.sh`](../examples/company-lookup.sh) for a complete example
184
+ of an AI-generated script that validates prerequisites and calls MCP tools.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/mcpc",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Universal command-line client for the Model Context Protocol (MCP).",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -30,7 +30,7 @@
30
30
  "scripts": {
31
31
  "build": "tsc",
32
32
  "build:watch": "tsc --watch",
33
- "build:toc": "doctoc README.md --github --notitle && sed -i '' '/^- \\[mcpc:/d' README.md",
33
+ "build:readme": "./scripts/update-readme.sh",
34
34
  "test": "npm run build && npm run test:unit && ./test/e2e/run.sh --no-build",
35
35
  "test:unit": "jest",
36
36
  "test:watch": "jest --watch",
@@ -45,7 +45,7 @@
45
45
  "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
46
46
  "clean": "rm -rf dist",
47
47
  "prebuild": "npm run clean",
48
- "prepublishOnly": "npm run lint && npm run build && npm test",
48
+ "prepublishOnly": "npm run lint && npm run build:readme && npm run build && npm run test:unit && ./test/e2e/run.sh --no-build --parallel 1",
49
49
  "release": "bash scripts/publish.sh",
50
50
  "release:minor": "bash scripts/publish.sh minor",
51
51
  "release:major": "bash scripts/publish.sh major"
@@ -72,6 +72,7 @@
72
72
  "doctoc": "^2.2.1",
73
73
  "eslint": "^8.57.1",
74
74
  "jest": "^30.2.0",
75
+ "markdown-link-check": "^3.14.2",
75
76
  "nyc": "^17.1.0",
76
77
  "prettier": "^3.7.4",
77
78
  "ts-jest": "^29.4.6",
package/PUBLISHING.md DELETED
@@ -1,111 +0,0 @@
1
- # Publishing Guide
2
-
3
- ## Reserve Package Name (Placeholder)
4
-
5
- To reserve the `mcpc` package name on npm without publishing the full implementation:
6
-
7
- 1. Make sure you're logged in to npm:
8
- ```bash
9
- npm login
10
- ```
11
-
12
- 2. Run the placeholder publish script:
13
- ```bash
14
- npm run publish:placeholder
15
- ```
16
-
17
- This will publish `mcpc@0.0.1` with a minimal placeholder that:
18
- - Reserves the package name
19
- - Points users to the GitHub repository
20
- - Clearly indicates the package is under development
21
-
22
- ## Publish Full Version
23
-
24
- When ready to publish the full implementation:
25
-
26
- 1. **Ensure everything is ready:**
27
- ```bash
28
- npm run build
29
- npm test
30
- npm run lint
31
- ```
32
-
33
- 2. **Update version** (choose appropriate level):
34
- ```bash
35
- npm version patch # 0.0.1 -> 0.0.2
36
- npm version minor # 0.0.x -> 0.1.0
37
- npm version major # 0.x.x -> 1.0.0
38
- ```
39
-
40
- 3. **Publish:**
41
- ```bash
42
- npm publish --access public
43
- ```
44
-
45
- The `prepublishOnly` script will automatically:
46
- - Clean the dist folder
47
- - Run the build
48
- - Run all tests
49
-
50
- 4. **Push git tags:**
51
- ```bash
52
- git push --follow-tags
53
- ```
54
-
55
- ## What Gets Published
56
-
57
- Files included in the npm package (see `.npmignore`):
58
- - ✅ `dist/` - Compiled JavaScript
59
- - ✅ `bin/` - CLI executables
60
- - ✅ `package.json`
61
- - ✅ `README.md`
62
- - ✅ `LICENSE`
63
-
64
- Files excluded:
65
- - ❌ `src/` - TypeScript source (users only need compiled JS)
66
- - ❌ `test/` - Test files
67
- - ❌ `scripts/` - Development scripts
68
- - ❌ Config files (tsconfig.json, etc.)
69
-
70
- ## Testing the Package Locally
71
-
72
- Before publishing, test what will be included:
73
-
74
- ```bash
75
- # See what files will be published
76
- npm pack --dry-run
77
-
78
- # Create a tarball to inspect
79
- npm pack
80
-
81
- # Test installation locally
82
- npm install -g ./mcpc-0.1.0.tgz
83
- mcpc --help
84
- npm uninstall -g mcpc
85
- ```
86
-
87
- ## Version Strategy
88
-
89
- - `0.0.x` - Placeholder / early development
90
- - `0.1.0` - First functional release (direct connection working)
91
- - `0.2.0` - Add session management / bridge process
92
- - `0.3.0` - Add interactive shell
93
- - `1.0.0` - Stable release with all core features
94
-
95
- ## Troubleshooting
96
-
97
- ### "You do not have permission to publish"
98
- Make sure you're logged in: `npm whoami`
99
-
100
- ### "Package name too similar to existing package"
101
- The name `mcpc` should be available, but if not, consider:
102
- - `@apify/mcpc` (scoped package)
103
- - `mcp-cli`
104
- - `mcpcli`
105
-
106
- ### "prepublishOnly script failed"
107
- Fix any build or test errors before publishing:
108
- ```bash
109
- npm run build
110
- npm test
111
- ```
package/TODOs.md DELETED
@@ -1,46 +0,0 @@
1
-
2
- # TODOs
3
-
4
- ## Next
5
-
6
- - Simplify README - there are too many top-level sections, and then show just the second level ones
7
- - in README, explain the MCP commands better in a standalone section, with details how they work
8
- - Expand --help to use same text as in README, add link to README
9
-
10
- - We support "prompts", "tools" etc commands ... do we need to?
11
-
12
- ## MCP features
13
-
14
- - Add `--proxy [HOST:]PORT` feature to `connect` command to enable MCP proxy:
15
- - `--proxy-bearer-token X` for proxy to require auth token for better security
16
- - `--proxy-capabilities tools:TOOL_NAME,TOOL_NAME2,...,prompts[:...],...` to limit access to selected MCP features and tools
17
- (what if tools have ":" or "," in their names?)
18
- In theory, we could add limit of capabilities to normal sessions, but the LLM could still break out of it, so what's the point.
19
- Explain this is useful for AI sandboxing!
20
- - Implement resources-subscribe/resources-unsubscribe, --o file command properly, --max-size
21
- automatically update the -o file on changes, without it just keep track of changed files in
22
- bridge process' cache, and report in resources-list/resources-read operation
23
- - Add support for asynchronous tasks
24
- - Add support for client roots, need to figure how exactly
25
-
26
- ## Later
27
-
28
- - Check how we deal with connection and command timeouts, that --timeout and timeout from config
29
- file are obeyed
30
-
31
- - Consider adding support for MCP elicitations, and potentially for sampling (e.g. via shell
32
- interface?)
33
-
34
- - nit: Cooler OAuth flow finish web page with CSS animation, add Apify example there, show mcpc info. E.g. next step - check Apify rather than close
35
- - nit: For auth profiles, fetch the detailed user info via http, ensure the info is up-to-date
36
- - nit: add more shortcuts, e.g. --profile => -p
37
- - later: Add unique Session.id and Profile.id and use it for OS keychain keys, to truly enable using multiple independent mcpc profiles
38
- - nit: Implement typing completions (e.g. "mcpc @a...") - not sure if that's even possible
39
-
40
-
41
- ## E2E test scenarios
42
-
43
- Later
44
- - Test auth profiles work long-term and sessions too - basically when running some tests the
45
- next day they should use old saved auths and sessions.
46
- We could have some special dir for long-term testing...