@apify/mcpc 0.1.0 → 0.1.3

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 (95) hide show
  1. package/.claude/settings.local.json +6 -2
  2. package/.idea/workspace.xml +283 -274
  3. package/README.md +190 -112
  4. package/TODOs.md +39 -48
  5. package/dist/bridge/index.js +131 -76
  6. package/dist/bridge/index.js.map +1 -1
  7. package/dist/cli/commands/auth.js +1 -1
  8. package/dist/cli/commands/auth.js.map +1 -1
  9. package/dist/cli/commands/clean.d.ts.map +1 -1
  10. package/dist/cli/commands/clean.js +31 -56
  11. package/dist/cli/commands/clean.js.map +1 -1
  12. package/dist/cli/commands/sessions.d.ts.map +1 -1
  13. package/dist/cli/commands/sessions.js +115 -40
  14. package/dist/cli/commands/sessions.js.map +1 -1
  15. package/dist/cli/helpers.d.ts +3 -0
  16. package/dist/cli/helpers.d.ts.map +1 -1
  17. package/dist/cli/helpers.js +91 -15
  18. package/dist/cli/helpers.js.map +1 -1
  19. package/dist/cli/index.js +13 -5
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/cli/output.d.ts.map +1 -1
  22. package/dist/cli/output.js +26 -4
  23. package/dist/cli/output.js.map +1 -1
  24. package/dist/cli/shell-parser.d.ts.map +1 -1
  25. package/dist/cli/shell-parser.js.map +1 -1
  26. package/dist/cli/shell.d.ts.map +1 -1
  27. package/dist/cli/shell.js +9 -8
  28. package/dist/cli/shell.js.map +1 -1
  29. package/dist/core/factory.d.ts +2 -0
  30. package/dist/core/factory.d.ts.map +1 -1
  31. package/dist/core/factory.js +3 -1
  32. package/dist/core/factory.js.map +1 -1
  33. package/dist/core/mcp-client.d.ts.map +1 -1
  34. package/dist/core/mcp-client.js +8 -12
  35. package/dist/core/mcp-client.js.map +1 -1
  36. package/dist/core/transports.d.ts +5 -1
  37. package/dist/core/transports.d.ts.map +1 -1
  38. package/dist/core/transports.js +39 -9
  39. package/dist/core/transports.js.map +1 -1
  40. package/dist/lib/auth/keychain.d.ts.map +1 -1
  41. package/dist/lib/auth/keychain.js +5 -2
  42. package/dist/lib/auth/keychain.js.map +1 -1
  43. package/dist/lib/auth/oauth-flow.d.ts.map +1 -1
  44. package/dist/lib/auth/oauth-flow.js +11 -2
  45. package/dist/lib/auth/oauth-flow.js.map +1 -1
  46. package/dist/lib/auth/oauth-provider.d.ts +19 -8
  47. package/dist/lib/auth/oauth-provider.d.ts.map +1 -1
  48. package/dist/lib/auth/oauth-provider.js +95 -27
  49. package/dist/lib/auth/oauth-provider.js.map +1 -1
  50. package/dist/lib/auth/oauth-token-manager.d.ts +8 -0
  51. package/dist/lib/auth/oauth-token-manager.d.ts.map +1 -1
  52. package/dist/lib/auth/oauth-token-manager.js +43 -0
  53. package/dist/lib/auth/oauth-token-manager.js.map +1 -1
  54. package/dist/lib/auth/{auth-profiles.d.ts → profiles.d.ts} +2 -1
  55. package/dist/lib/auth/profiles.d.ts.map +1 -0
  56. package/dist/lib/auth/{auth-profiles.js → profiles.js} +26 -10
  57. package/dist/lib/auth/profiles.js.map +1 -0
  58. package/dist/lib/auth/token-refresh.js +1 -1
  59. package/dist/lib/auth/token-refresh.js.map +1 -1
  60. package/dist/lib/bridge-client.js.map +1 -1
  61. package/dist/lib/bridge-manager.d.ts +0 -1
  62. package/dist/lib/bridge-manager.d.ts.map +1 -1
  63. package/dist/lib/bridge-manager.js +32 -46
  64. package/dist/lib/bridge-manager.js.map +1 -1
  65. package/dist/lib/cleanup.d.ts +5 -0
  66. package/dist/lib/cleanup.d.ts.map +1 -0
  67. package/dist/lib/cleanup.js +48 -0
  68. package/dist/lib/cleanup.js.map +1 -0
  69. package/dist/lib/errors.d.ts +1 -1
  70. package/dist/lib/errors.d.ts.map +1 -1
  71. package/dist/lib/errors.js +5 -1
  72. package/dist/lib/errors.js.map +1 -1
  73. package/dist/lib/index.d.ts +1 -0
  74. package/dist/lib/index.d.ts.map +1 -1
  75. package/dist/lib/index.js +1 -0
  76. package/dist/lib/index.js.map +1 -1
  77. package/dist/lib/session-client.d.ts.map +1 -1
  78. package/dist/lib/session-client.js +7 -7
  79. package/dist/lib/session-client.js.map +1 -1
  80. package/dist/lib/sessions.d.ts +6 -1
  81. package/dist/lib/sessions.d.ts.map +1 -1
  82. package/dist/lib/sessions.js +71 -13
  83. package/dist/lib/sessions.js.map +1 -1
  84. package/dist/lib/types.d.ts +6 -3
  85. package/dist/lib/types.d.ts.map +1 -1
  86. package/dist/lib/utils.d.ts +2 -1
  87. package/dist/lib/utils.d.ts.map +1 -1
  88. package/dist/lib/utils.js +16 -3
  89. package/dist/lib/utils.js.map +1 -1
  90. package/docs/claude-skill/README.md +38 -0
  91. package/docs/claude-skill/SKILL.md +159 -0
  92. package/package.json +8 -3
  93. package/PHASE1-SUMMARY.md +0 -269
  94. package/dist/lib/auth/auth-profiles.d.ts.map +0 -1
  95. package/dist/lib/auth/auth-profiles.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # mcpc: an MCP command-line client
1
+ # mcpc: Universal MCP command-line client
2
2
 
3
- `mcpc` is a universal command-line client for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/),
4
- which maps MCP to intuitive CLI commands for shell access, scripts, and AI coding agents.
3
+ `mcpc` is a CLI for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/),
4
+ which maps MCP operations to intuitive commands for interactive shell use, scripts, and AI coding agents.
5
5
 
6
6
  `mcpc` can connect to any MCP server over Streamable HTTP or stdio transports,
7
7
  securely login via OAuth credentials and store credentials,
@@ -11,16 +11,86 @@ It supports all major MCP features, including tools, resources, prompts, asynchr
11
11
  `mcpc` is handy for manual testing of MCP servers, scripting,
12
12
  and AI coding agents to use MCP in ["code mode"](https://www.anthropic.com/engineering/code-execution-with-mcp),
13
13
  for better accuracy and lower token compared to traditional tool function calling.
14
- After all, UNIX-compatible shell script is THE most universal coding language, for both people and LLMs.
15
-
16
- Note that `mcpc` is deterministic and does not use any LLM on its own; that's for the higher layer to do.
14
+ After all, UNIX-compatible shell script is THE most universal coding language, for people and LLMs alike.
15
+
16
+ Note that `mcpc` is deterministic and does not use any LLM on its own; that's left for the higher layer.
17
+
18
+ <!--
19
+ ## Table of contents
20
+
21
+ TODO: Simplify README - there are too many top-level sections, and then show just the second level ones
22
+ -->
23
+
24
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
25
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
26
+ <!--
27
+ - [Features](#features)
28
+ - [Install](#install)
29
+ - [Quickstart](#quickstart)
30
+ - [Usage](#usage)
31
+ - [MCP command arguments](#mcp-command-arguments)
32
+ - [Global flags](#global-flags)
33
+ - [Authentication](#authentication)
34
+ - [No authentication](#no-authentication)
35
+ - [Bearer token authentication](#bearer-token-authentication)
36
+ - [OAuth authentication](#oauth-authentication)
37
+ - [Authentication profiles](#authentication-profiles)
38
+ - [Authentication behavior](#authentication-behavior)
39
+ - [Multiple accounts for the same server](#multiple-accounts-for-the-same-server)
40
+ - [Authentication precedence](#authentication-precedence)
41
+ - [Authentication profiles storage format](#authentication-profiles-storage-format)
42
+ - [Sessions](#sessions)
43
+ - [Managing sessions](#managing-sessions)
44
+ - [Piping between sessions](#piping-between-sessions)
45
+ - [Scripting](#scripting)
46
+ - [Session failover](#session-failover)
47
+ - [Logging](#logging)
48
+ - [Cleanup](#cleanup)
49
+ - [Configuration](#configuration)
50
+ - [MCP config JSON file](#mcp-config-json-file)
51
+ - [Environment variables](#environment-variables)
52
+ - [MCP protocol notes](#mcp-protocol-notes)
53
+ - [Output format](#output-format)
54
+ - [Human-readable (default)](#human-readable-default)
55
+ - [JSON mode (`--json`)](#json-mode---json)
56
+ - [Security](#security)
57
+ - [Credential storage](#credential-storage)
58
+ - [Bridge process authentication](#bridge-process-authentication)
59
+ - [File permissions](#file-permissions)
60
+ - [Network security](#network-security)
61
+ - [Error handling](#error-handling)
62
+ - [Exit codes](#exit-codes)
63
+ - [Retry strategy](#retry-strategy)
64
+ - [Interactive shell](#interactive-shell)
65
+ - [Claude Code skill](#claude-code-skill)
66
+ - [Troubleshooting](#troubleshooting)
67
+ - [Common issues](#common-issues)
68
+ - [Debug mode](#debug-mode)
69
+ - [Logs](#logs)
70
+ - [Development](#development)
71
+ - [Design principles](#design-principles)
72
+ - [Architecture overview](#architecture-overview)
73
+ - [Core module (runtime-agnostic)](#core-module-runtime-agnostic)
74
+ - [Bridge process](#bridge-process)
75
+ - [CLI executable](#cli-executable)
76
+ - [Session lifecycle](#session-lifecycle)
77
+ - [Error recovery](#error-recovery)
78
+ - [Testing strategy](#testing-strategy)
79
+ - [Contributing](#contributing)
80
+ - [Development setup](#development-setup)
81
+ - [Release process](#release-process)
82
+ - [References](#references)
83
+ - [Authors](#authors)
84
+ - [License](#license)
85
+ -->
86
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
17
87
 
18
88
  ## Features
19
89
 
20
90
  - 🔌 **Universal MCP client** - Works with any MCP server over Streamable HTTP or stdio.
21
91
  - 🔄 **Persistent sessions** - Keep multiple server connections alive simultaneously.
22
92
  - 🚀 **Zero setup** - Connect to remote servers instantly with just a URL.
23
- - 🔧 **Full protocol support** - Tools, resources, prompts, sampling, dynamic discovery, and async notifications.
93
+ - 🔧 **Full protocol support** - Tools, resources, prompts, dynamic discovery, and async notifications.
24
94
  - 📊 **`--json` output** - Easy integration with `jq`, scripts, and other CLI tools.
25
95
  - 🤖 **AI-friendly** - Designed for code generation and automated workflows.
26
96
  - 🔒 **Secure** - OS keychain integration for credentials, encrypted auth storage.
@@ -60,8 +130,7 @@ mcpc @test shell
60
130
 
61
131
  ```bash
62
132
  mcpc [--json] [--config <file>] [-H|--header "K: V"] [-v|--verbose]
63
- [--schema <file>]
64
- [--schema-mode <mode>] [--timeout <seconds>] [--insecure]
133
+ [--schema <file>] [--schema-mode <mode>] [--timeout <seconds>]
65
134
  [--clean|--clean=sessions,logs,profiles,all]
66
135
  <target> <command...>
67
136
 
@@ -83,8 +152,8 @@ mcpc <target> prompts-get <prompt-name> [--args key=val key2:=json ...] [--args-
83
152
 
84
153
  mcpc <target> resources
85
154
  mcpc <target> resources-list
86
- mcpc <target> resources-read <uri> [-o <file>] [--max-size <bytes>]
87
- mcpc <target> resources-subscribe <uri> # TODO
155
+ mcpc <target> resources-read <uri>
156
+ mcpc <target> resources-subscribe <uri>
88
157
  mcpc <target> resources-unsubscribe <uri>
89
158
  mcpc <target> resources-templates-list
90
159
 
@@ -156,7 +225,6 @@ echo '{"query":"hello","count":10}' | mcpc @server tools-call my-tool
156
225
  - `--timeout <seconds>` - Request timeout in seconds (default: 300)
157
226
  - `--schema <file>` - Validate against expected tool/prompt schema
158
227
  - `--schema-mode <mode>` - Schema validation mode: `strict`, `compatible`, or `ignore` (default: `compatible`)
159
- - `--insecure` - Disable SSL certificate validation (not recommended)
160
228
 
161
229
  ## Authentication
162
230
 
@@ -212,7 +280,7 @@ This allows you to:
212
280
  - Manage credentials independently from sessions
213
281
 
214
282
  **Key concepts:**
215
- - **Authentication profile**: Named set of OAuth credentials for a specific server (stored in `~/.mcpc/auth-profiles.json` + OS keychain)
283
+ - **Authentication profile**: Named set of OAuth credentials for a specific server (stored in `~/.mcpc/profiles.json` + OS keychain)
216
284
  - **Session**: Active connection to a server that may reference an authentication profile (stored in `~/.mcpc/sessions.json`)
217
285
  - **Default profile**: When `--profile` is not specified, `mcpc` uses the authentication profile named `default`
218
286
 
@@ -317,7 +385,7 @@ When multiple authentication methods are available, `mcpc` uses this precedence
317
385
 
318
386
  ### Authentication profiles storage format
319
387
 
320
- By default, authentication profiles are stored in the `~/.mcpc/auth-profiles.json` file with the following structure:
388
+ By default, authentication profiles are stored in the `~/.mcpc/profiles.json` file with the following structure:
321
389
 
322
390
  ```json
323
391
  {
@@ -371,7 +439,7 @@ Instead of forcing every command to reconnect and reinitialize (which is slow an
371
439
  `mcpc` saves its state to `~/.mcpc/` directory (unless overridden by `MCPC_HOME_DIR`), in the following files:
372
440
 
373
441
  - `~/.mcpc/sessions.json` - Active sessions with references to authentication profiles (file-locked for concurrent access)
374
- - `~/.mcpc/auth-profiles.json` - Authentication profiles (OAuth metadata, scopes, expiry)
442
+ - `~/.mcpc/profiles.json` - Authentication profiles (OAuth metadata, scopes, expiry)
375
443
  - `~/.mcpc/bridges/` - Unix domain socket files for each bridge process
376
444
  - `~/.mcpc/logs/bridge-*.log` - Log files for each bridge process
377
445
  - OS keychain - Sensitive credentials (OAuth tokens, bearer tokens, client secrets)
@@ -468,7 +536,7 @@ mcpc https://mcp.apify.com session @apify
468
536
 
469
537
  ## Logging
470
538
 
471
- The background bridge process logs to `~/.mcpc/bridges/mcpc-@<session-name>.log`.
539
+ The background bridge process logs to `~/.mcpc/logs/bridge-<session-name>.log`.
472
540
  The main `mcpc` process doesn't save log files, but you can use `--verbose` flag to print all logs to stderr.
473
541
 
474
542
  MCP servers can be instructed to adjust their [logging level](https://modelcontextprotocol.io/specification/latest/server/utilities/logging)
@@ -495,6 +563,24 @@ mcpc @apify logging-set-level error
495
563
  **Note:** This sets the logging level on the **server side**. The actual log output depends on the server's implementation.
496
564
 
497
565
 
566
+ ## Cleanup
567
+
568
+ You can clean up the `mcpc` state and data using the `--clean` option:
569
+
570
+ ```bash
571
+ # Safe non-destructive cleanup: remove expired sessions, delete old orphaned logs
572
+ mcpc --clean
573
+
574
+ # Clean specific resources (comma-separated)
575
+ mcpc --clean=sessions # Kill bridges, delete all sessions
576
+ mcpc --clean=profiles # Delete all authentication profiles
577
+ mcpc --clean=logs # Delete all log files
578
+ mcpc --clean=sessions,logs # Clean multiple resource types
579
+
580
+ # Nuclear option: remove everything
581
+ mcpc --clean=all # Delete all sessions, profiles, logs, and sockets
582
+ ```
583
+
498
584
  ## Configuration
499
585
 
500
586
  Configuration can be provided via file, environment variables, or command-line flags.
@@ -612,7 +698,7 @@ Config files support environment variable substitution using `${VAR_NAME}` synta
612
698
  - **Tools**: Executable functions with JSON Schema-validated arguments.
613
699
  - **Resources**: Data sources identified by URIs (e.g., `file:///path/to/file`, `https://example.com/data`), with optional subscriptions for change notifications
614
700
  - **Prompts**: Reusable message templates with customizable arguments
615
- - **Completion**: Provides access to Completion API for tools and resources, and offers completions in shell mode
701
+ - **Completion**: Provides access to Completion API for tools and resources
616
702
  - Supports server logging settings (`logging/setLevel`) and messages (`notifications/message`), and prints them to stderr or stdout based on verbosity level.
617
703
  - Handles server notifications: progress tracking, logging, and change notifications (`notifications/tools/list_changed`, `notifications/resources/list_changed`, `notifications/prompts/list_changed`)
618
704
  - Request multiplexing: supports up to 10 concurrent requests, queues up to 100 additional requests
@@ -647,7 +733,7 @@ MCP enables arbitrary tool execution and data access; treat servers like you tre
647
733
  - OAuth refresh tokens are stored in the OS keychain (access tokens are kept in memory only)
648
734
  - OAuth client credentials (client_id, client_secret from dynamic registration) are stored in the keychain
649
735
  - All HTTP headers from `--header` flags are stored per-session in the keychain (as JSON)
650
- - The `~/.mcpc/auth-profiles.json` file only contains metadata (server URL, scopes, timestamps) - never tokens
736
+ - The `~/.mcpc/profiles.json` file only contains metadata (server URL, scopes, timestamps) - never tokens
651
737
 
652
738
  **Keychain entries:**
653
739
  - OAuth tokens: `mcpc:auth:<serverUrl>:<profileName>:oauth-tokens`
@@ -683,14 +769,13 @@ This architecture ensures:
683
769
  ### File permissions
684
770
 
685
771
  - `~/.mcpc/sessions.json` is set to `0600` (user-only read/write)
686
- - `~/.mcpc/auth-profiles.json` is set to `0600` (user-only read/write)
772
+ - `~/.mcpc/profiles.json` is set to `0600` (user-only read/write)
687
773
  - Bridge sockets in `~/.mcpc/bridges/` are created with `0700` permissions
688
774
  - Log files in `~/.mcpc/logs/` are created with `0600` permissions
689
775
 
690
776
  ### Network security
691
777
 
692
778
  - HTTPS enforced for remote servers (HTTP auto-upgraded)
693
- - Certificate validation enabled (use `--insecure` to disable, not recommended)
694
779
  - `Origin` header validation to prevent DNS rebinding attacks
695
780
  - Local servers bind to localhost (127.0.0.1) only
696
781
  - No credentials logged even in verbose mode
@@ -731,9 +816,8 @@ mcpc @apify shell
731
816
  ```
732
817
 
733
818
  **Features:**
734
- - Command history (saved to `~/.mcpc/history`, last 1000 commands)
735
- - Tab completion for commands, tool names, and resource URIs
736
- - Multi-line editing with arrow keys
819
+ - Command history with arrow key navigation (saved to `~/.mcpc/history`, last 1000 commands)
820
+ - Real-time server notifications displayed during session
737
821
  - Prompt shows session name: `mcpc(@apify)> `
738
822
 
739
823
  **Shell-specific commands:**
@@ -759,48 +843,81 @@ mcpc(@apify)> tools-call search-actors --args query="tiktok scraper"
759
843
  mcpc(@apify)> exit
760
844
  ```
761
845
 
762
- ## Implementation status
846
+ ## Claude Code skill
763
847
 
764
- **Note:** This README describes the target architecture. `mcpc` is under active development and not all features are currently implemented.
848
+ For AI coding agents using [Claude Code](https://claude.ai/code), we provide a skill that teaches Claude how to use mcpc effectively.
765
849
 
766
- ### What's implemented
850
+ **Installation:**
851
+ ```bash
852
+ mkdir -p ~/.claude/skills/mcpc
853
+ cp claude-skill/SKILL.md ~/.claude/skills/mcpc/
854
+ ```
767
855
 
768
- **✅ Core functionality:**
769
- - MCP protocol client (wrapper around official SDK)
770
- - CLI structure with Commander.js
771
- - All MCP command handlers fully functional
772
- - Output formatting (human-readable and JSON modes)
773
- - Argument parsing (inline JSON, key=value, key:=json, `--args-file`)
774
- - Error handling with exit codes
775
- - Verbose logging
776
- - Bridge process with persistent sessions
777
- - Unix socket IPC between CLI and bridge
778
- - Session management with file locking
779
- - Environment variables (MCPC_HOME_DIR, MCPC_VERBOSE, MCPC_JSON)
780
- - Caching with TTL and notification-based invalidation
781
- - Server notification handling (`list_changed` events)
782
- - Per-session bridge logs with rotation
783
- - Interactive shell: REPL features (history, tab completion)
784
- - Config file: Full stdio transport support for local packages
785
- - **Authentication**: OAuth profiles, keychain storage (structure exists, flow not complete)
786
- - **Error recovery**: Bridge crash recovery, automatic reconnection
856
+ Then restart Claude Code. The skill enables Claude to interact with MCP servers via mcpc commands instead of function calling, which is more efficient and uses fewer tokens.
857
+
858
+ See [`claude-skill/README.md`](./claude-skill/README.md) for details.
859
+
860
+
861
+ ## Troubleshooting
862
+
863
+ ### Common issues
864
+
865
+ **"Cannot connect to bridge"**
866
+ - Bridge may have crashed. Try: `mcpc <server> session @<session-name>`
867
+ - Check bridge is running: `ps aux | grep -e 'mcpc-bridge' -e '[m]cpc/dist/bridge'`
868
+ - Check socket exists: `ls ~/.mcpc/bridges/`
869
+
870
+ **"Session not found"**
871
+ - Session may have expired. Create new session: `mcpc <target> session @<session-name>`
872
+ - List existing sessions: `mcpc`
873
+
874
+ **"Authentication failed"**
875
+ - List saved profiles: `mcpc`
876
+ - Re-authenticate: `mcpc <server> login [--profile <name>]`
877
+ - For bearer tokens: provide `--header "Authorization: Bearer ${TOKEN}"` again
878
+
879
+ ### Debug mode
880
+
881
+ Enable detailed logging with `--verbose`:
882
+
883
+ ```bash
884
+ mcpc --verbose @apify tools-list
885
+ ```
886
+
887
+ This shows:
888
+ - Protocol negotiation details
889
+ - JSON-RPC request/response messages
890
+ - Streaming events and reconnection attempts
891
+ - Bridge communication (socket messages)
892
+ - File locking operations
893
+ - Prints server log messages with severity `debug`, `info`, and `notice` to standard output
894
+
895
+ ### Logs
896
+
897
+ Bridge processes log to:
898
+ - `~/.mcpc/logs/bridge-<session-name>.log`
899
+
900
+ Log rotation: Keep last 10MB per session, max 5 files.
787
901
 
788
- ## Implementation details
902
+ ## Development
903
+
904
+ `mcpc` is under active development and some things might not work 100% yet. You have been warned.
789
905
 
790
906
  ### Design principles
791
907
 
792
908
  - Delightful for humans and AI agents alike (interactive + scripting)
793
- - One clear way to do things (orthogonal commands, no surprises, saving tokens)
794
- - Do not ask for user input (except `shell` and `login`)
795
- - Be forgiving, always help users make forward progress (great errors + guidance)
796
- - JSON strictly consistency with the MCP specification
909
+ - Avoid unnecessary interaction loops, provide sufficient context, yet be concise (save tokens)
910
+ - One clear way to do things (orthogonal commands, no surprises)
911
+ - Do not ask for user input (except `shell` and `login`, no unexpected OAuth flows)
912
+ - Be forgiving, always help users make progress (great errors + guidance)
913
+ - Be consistent with the [MCP specification](https://modelcontextprotocol.io/specification/latest), with `--json` strictly
797
914
  - Minimal and portable (few deps, cross-platform)
798
915
  - No slop!
799
916
 
800
917
  ### Architecture overview
801
918
 
802
919
  ```
803
- TODO: improve interaction diagram
920
+ TODO: add interaction diagram
804
921
  mcpc ──> cli ├──> bridge (UNIX socket) ──> MCP server (stdio/HTTP)
805
922
  ├──> MCP server (stdio/HTTP)
806
923
 
@@ -815,7 +932,6 @@ mcpc (single package)
815
932
  │ └── mcpc-bridge # Bridge process executable
816
933
  ```
817
934
 
818
-
819
935
  ### Core module (runtime-agnostic)
820
936
 
821
937
  Implemented with minimal dependencies to support both Node.js (≥18.0.0) and Bun (≥1.0.0).
@@ -868,18 +984,18 @@ Implemented as a separate executable (`mcpc-bridge`) that maintains persistent c
868
984
  The main `mcpc` command provides the user interface.
869
985
 
870
986
  **CLI responsibilities:**
871
- - Argument parsing (using `minimist` or similar)
987
+ - Argument parsing using Commander.js
872
988
  - Output formatting (human-readable vs `--json`)
873
989
  - Bridge lifecycle: start/connect/stop
874
990
  - Communication with bridge via socket
875
- - Interactive shell (REPL using `@inquirer/prompts`)
991
+ - Interactive shell (REPL using Node.js `readline`)
876
992
  - Configuration file loading (standard MCP JSON format)
877
993
  - Credential management (OS keychain via `keytar` package)
878
994
 
879
995
  **Shell implementation:**
880
- - Built on `@inquirer/prompts` for input handling
881
- - Command history using `~/.mcpc/history`
882
- - Tab completion using inquirer autocomplete and MCP completion API
996
+ - Built on Node.js `readline` module for input handling with history support
997
+ - Command history using `~/.mcpc/history` (last 1000 commands)
998
+ - Real-time notification display during shell sessions
883
999
  - Graceful exit handling (cleanup on Ctrl+C/Ctrl+D)
884
1000
 
885
1001
  ### Session lifecycle
@@ -952,47 +1068,6 @@ Later...
952
1068
  - `examples/test-server/` - Reference MCP server for testing
953
1069
  - `test/mock-keychain.ts` - Mock OS keychain for testing
954
1070
 
955
- ## Troubleshooting
956
-
957
- ### Common issues
958
-
959
- **"Cannot connect to bridge"**
960
- - Bridge may have crashed. Try: `mcpc <server> session @<session-name>`
961
- - Check bridge is running: `ps aux | grep -e 'mcpc-bridge' -e '[m]cpc/dist/bridge'`
962
- - Check socket exists: `ls ~/.mcpc/bridges/`
963
-
964
- **"Session not found"**
965
- - Session may have expired. Create new session: `mcpc <target> session @<session-name>`
966
- - List existing sessions: `mcpc`
967
-
968
- **"Authentication failed"**
969
- - List saved profiles: `mcpc`
970
- - Re-authenticate: `mcpc <server> login [--profile <name>]`
971
- - For bearer tokens: provide `--header "Authorization: Bearer ${TOKEN}"` again
972
-
973
- ### Debug mode
974
-
975
- Enable detailed logging with `--verbose`:
976
-
977
- ```bash
978
- mcpc --verbose @apify tools-list
979
- ```
980
-
981
- This shows:
982
- - Protocol negotiation details
983
- - JSON-RPC request/response messages
984
- - Streaming events and reconnection attempts
985
- - Bridge communication (socket messages)
986
- - File locking operations
987
- - Prints server log messages with severity `debug`, `info`, and `notice` to standard output
988
-
989
- ### Logs
990
-
991
- Bridge processes log to:
992
- - `~/.mcpc/logs/bridge-<session-name>.log`
993
-
994
- Log rotation: Keep last 10MB per session, max 5 files.
995
-
996
1071
  ## Contributing
997
1072
 
998
1073
  Contributions are welcome!
@@ -1020,23 +1095,26 @@ mcpc --help
1020
1095
 
1021
1096
  ### Release process
1022
1097
 
1023
- ```bash
1024
- # Run tests
1025
- npm test
1098
+ Use the release script to publish a new version (must be on `main` branch):
1026
1099
 
1027
- # Build
1028
- npm run build
1029
-
1030
- # Bump version
1031
- npm version patch|minor|major
1032
-
1033
- # Publish
1034
- npm publish
1035
-
1036
- # Push tags
1037
- git push --tags
1100
+ ```bash
1101
+ npm run release # patch version bump (0.1.2 → 0.1.3)
1102
+ npm run release:minor # minor version bump (0.1.2 → 0.2.0)
1103
+ npm run release:major # major version bump (0.1.2 → 1.0.0)
1038
1104
  ```
1039
1105
 
1106
+ The script automatically:
1107
+ - Ensures you're on `main` branch
1108
+ - Ensures working directory is clean (no uncommitted changes)
1109
+ - Ensures branch is up-to-date with remote
1110
+ - Runs lint, build, and tests
1111
+ - Bumps the version in package.json
1112
+ - Creates a git commit and annotated tag (`v{version}`)
1113
+ - Pushes the commit and tag to origin
1114
+ - Publishes to npm
1115
+
1116
+ After publishing, create a GitHub release at the provided link.
1117
+
1040
1118
  Please open an issue or pull request on [GitHub](https://github.com/apify/mcpc).
1041
1119
 
1042
1120
 
package/TODOs.md CHANGED
@@ -1,94 +1,85 @@
1
1
 
2
2
  # TODOs
3
3
 
4
-
5
4
  ## Bugs
6
- - Seems calling invalid/unknown MCP command in shell (perhaps also normally) causes the bridge to be flagged as expired
7
-
8
- - reconnection doesn't work
9
- mcpc @apify session  1 ✘
10
- error: missing required argument 'name'
11
-
5
+ ...
12
6
 
13
7
 
14
8
  ## Next
15
9
 
16
- - nit: consistent good server and session info, on server/session info, print also auth info
17
- - [Using session: apify-docs] => change to show server + transport + version? + auth info!!!
18
- Active MCP sessions:
19
- @fs → npx (stdio) --- show also args instead of just "npx"
20
- - print PID of bridge process
21
-
22
- Visual examples:
23
-
24
- Xxx/
25
- ├── run.sh # Master runner (parallel by suite)
26
- ├── lib/
27
- │ ├── common.sh # Assertions, temp dirs, cleanup
28
- │ ├── server.sh # Start/stop test server helpers
29
- │ └── mcpc.sh # Wrapper to invoke mcpc with coverage
30
- ├── fixtures/
31
- │ └── configs/ # Test config files
32
- ├── server/
33
- │ └── index.ts # Configurable test MCP server
34
-
10
+ - Expand --help to use same text as in README, add link to README
35
11
 
36
- * ▐▛███▜▌ * Claude Code v2.0.75
37
- * ▝▜█████▛▘ * Opus 4.5 · Claude Team
38
- * ▘▘ ▝▝ * ~/Projects/mcpc
12
+ BIG: We need to decide whether to show Markdown-ish or not
39
13
 
40
14
 
41
- - Better error handling:
42
- - "mcpc https://mcp.sentry.dev/mcp" with an unknown sever => should hint to use "login"
43
- - Handle MCP errors by failing the command tool, e.g. invalid tool name..
44
-
45
- - implement resources-subscribe/resources-unsubscribe command properly
15
+ - implement resources-subscribe/resources-unsubscribe, --o file command properly, --max-size
46
16
  - > # TODO: automatically update the -o file on changes, without it just keep track of changed files in bridge process' cache, and report in resources-list
47
-
48
-
17
+
18
+
49
19
  ## Security
50
20
  - Double-check the MCP security guidelines
51
21
  - OAuth issuer - maybe save it and double-check it to ensure domain is not spoofed?
52
22
 
53
-
54
23
  ## Later
55
24
 
25
+ - nit: Print version info to logs, and link to https://github.com/apify/mcpc (to right release tag) - add this also to --help
26
+
27
+ - Implement "mcpc @session restart"
28
+
56
29
  - nit: Colorize output, e.g. JSONs in one color. MCP provided data like descriptions and instructions in orange.
57
30
  - warnings could be orange, errors red
58
- - - docs: add Claude Skills file to /docs, maybe also man page?
59
- - Add support for MCP elicitations, and potentially for sampling (e.g. via shell interface?)
31
+ - nit: Cooler OAuth flow finish web page with CSS animation, add Apify example there. E.g. next step - check Apify rather than close
32
+
60
33
  - Add `--proxy [HOST:]PORT` feature to `connect` command to enable MCP proxy:
61
34
  - `--proxy-bearer-token X` to require auth token for better security
62
35
  - `--proxy-capabilities tools:TOOL_NAME,TOOL_NAME2,...,prompts[:...],...` to limit access to selected MCP features and tools
63
36
  (what if tools have ":" or "," in their names?)
64
37
  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.
65
38
  - Explain this is useful for AI sandboxing!
66
- - Implement typing completions (e.g. "mcpc @a...") - not sure how difficult that is
67
- - nit: Nicer OAuth flow finish web page, add Apify example there. E.g. next step - check Apify rather than close
39
+
40
+ - For auth profiles, fetch the detailed user info from http, ensure the info is up-to-date
41
+ - Add support for MCP elicitations, and potentially for sampling (e.g. via shell interface?)
42
+
68
43
  - nit: cooler OAuth web pages "Authentication successful!" - show mcpc info
69
44
  - audit that on every command, we print next steps as examples
70
45
  - more shortcuts, e.g. --profile => -p
71
46
  - nit: in README, explain the MCP commands better in a standlone section, with details how they work
47
+ - Add unique Session.id and Profile.id and use it for OS keychain keys, to truly enable using multiple independent mcpc profiles
48
+ - When user runs --clean=profiles, print warning if some sessions were using them
49
+
50
+ - nit: Implement typing completions (e.g. "mcpc @a...") - not sure how difficult that is
51
+
52
+
72
53
 
73
54
 
74
55
 
75
56
  ## E2E test scenarios
76
- - add end-to-end tests e.g. under `test/e2e` - one bash script per test suite , organized in directories, and one master script that runs them all or selected ones (per directory) in parallel
77
- - Invariants:
57
+ - DONE: add end-to-end tests e.g. under `test/e2e` - one bash script per test suite , organized in directories,and one master script that runs them all or selected ones (per directory) in parallel
58
+ - Invariants (ideally test this for all commands used in other tests, or is it better just to always test one thing?):
78
59
  - --verbose only adds extra info to stderr, never to stdout
79
60
  - --json always returns single JSON object to stdout on success (exit code = 0), or an object or nothing at all on error (exit code != 0)
80
61
  - We'll need a testing server with all the available features and configurable, for testing.
62
+ - "npm run test:coverage" doesn't seem to work and cover e2e tests
81
63
  - Things to test:
82
64
  - handling of errors, invalid params, names, etc.
83
65
  - pagination
84
66
  - env vars...
85
- - stdio + filesystem operations,
67
+ - stdio + filesystem operations
86
68
  - sessions
69
+ - test stdio transport with fs mcp server
70
+ - test expired session (create fake record in session.json) - ensure attempts to use it will fail with the right error
87
71
  - for all commands, tests --verbose doesn't print anything extra to stdout, --json returns json
88
72
  - that on session close we send HTTP DELETE https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#session-management
89
- - Test session failover - e.g. kill the bridge process, and try to access the session again (should be restarted)
73
+ - Test session failover - e.g. kill the bridge process, and try to access the session again - should be restarted, work, and have same MCP-Session-Id
74
+ - Test auth - if no profile available and server requires OAuth, we need to fail with info what to do! e.g. "mcpc https://mcp.sentry.dev/mcp --verbose"
90
75
  - Test server session aborting - if session is aborted by server, bridge process should exit and set session status to "expired"
91
- - Test auth profiles work long-term and sessions too
92
- - Can we track test coverage also this way?
76
+ - Test auth profiles work long-term and sessions too - basically when running some tests the next day they should use old saved auths and sessions
77
+ - Test "mcpc @test close" and "mcpc <server> session @test" in rapid succession, it should work and use different pid (check sessions.json)
78
+ - Ensure calling invalid/unknown MCP command in shell and normally doesn't causes the bridge to be flagged as expired or dead
93
79
  - Text copy can change, but the core texts needs to be shown in both text and JSON mode
94
-
80
+ - Testing servers we can use:
81
+ - https://mcp.apify.com (for testing real OAuth login, we can create various accounts, both OAuth and API tokens)
82
+ - https://mcp.apify.com/tools=docs (anonymous, no auth needed)
83
+ - https://mcp.sentry.dev/mcp (for testing if no auth profile available)
84
+ - ideally get some on non-standard port, maybe localhost
85
+