@stellar_ai/mcp_fossil_scm 0.0.0-stage → 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.
Files changed (44) hide show
  1. package/README.md +170 -2
  2. package/dist/capabilities.d.ts +33 -0
  3. package/dist/capabilities.js +77 -0
  4. package/dist/capabilities.js.map +1 -0
  5. package/dist/cli.d.ts +27 -0
  6. package/dist/cli.js +160 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/config.d.ts +27 -0
  9. package/dist/config.js +61 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/core/fossil.d.ts +104 -0
  12. package/dist/core/fossil.js +254 -0
  13. package/dist/core/fossil.js.map +1 -0
  14. package/dist/core/sql.d.ts +29 -0
  15. package/dist/core/sql.js +58 -0
  16. package/dist/core/sql.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +13 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/server.d.ts +13 -0
  21. package/dist/server.js +41 -0
  22. package/dist/server.js.map +1 -0
  23. package/dist/tools/admin.d.ts +3 -0
  24. package/dist/tools/admin.js +160 -0
  25. package/dist/tools/admin.js.map +1 -0
  26. package/dist/tools/chat.d.ts +10 -0
  27. package/dist/tools/chat.js +150 -0
  28. package/dist/tools/chat.js.map +1 -0
  29. package/dist/tools/common.d.ts +9 -0
  30. package/dist/tools/common.js +20 -0
  31. package/dist/tools/common.js.map +1 -0
  32. package/dist/tools/forum.d.ts +3 -0
  33. package/dist/tools/forum.js +227 -0
  34. package/dist/tools/forum.js.map +1 -0
  35. package/dist/tools/tickets.d.ts +8 -0
  36. package/dist/tools/tickets.js +81 -0
  37. package/dist/tools/tickets.js.map +1 -0
  38. package/dist/tools/version-control.d.ts +3 -0
  39. package/dist/tools/version-control.js +400 -0
  40. package/dist/tools/version-control.js.map +1 -0
  41. package/dist/tools/wiki.d.ts +3 -0
  42. package/dist/tools/wiki.js +85 -0
  43. package/dist/tools/wiki.js.map +1 -0
  44. package/package.json +43 -3
package/README.md CHANGED
@@ -1,3 +1,171 @@
1
- # Temporary Holding Version
1
+ # fossil-scm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ MCP (Model Context Protocol) server for [Fossil SCM](https://fossil-scm.org/).
4
+
5
+ One binary, one list of capability letters: `--capability` decides which tool groups this process exposes,
6
+ so a client loads only what it needs.
7
+
8
+ | Letter | Capability | Tools | What it exposes |
9
+ | --- | --- | --- | --- |
10
+ | `a` | Admin | 5 | Repository lifecycle: `init`, `open`, `close`, `clone`, `settings` |
11
+ | `b` | VCS | 20 | Version control: status, diff, history, add/commit, branch, merge, update, undo, … |
12
+ | `c` | Forum | 3 | Forum thread list, thread reading and text search (read-only) |
13
+ | `d` | Tickets | 3 | Ticket reports, creation, field updates |
14
+ | `e` | Wiki | 3 | List, export and create/replace wiki pages |
15
+ | `f` | Chat | 4 | Chatroom URL, send, pull history, read locally stored messages |
16
+
17
+ The letters are consecutive, so a selection reads as a short string:
18
+ `-c b` (20 tools), `-c ab` (25), `-c de` (6), `-c cdf` (10), `-c all` (38, the default).
19
+
20
+ > Naming: the Fossil executable/command is `fossil`; this server is always called `fossil-scm`.
21
+
22
+ TypeScript rewrite of the original single-file Python server (`./,server.py`), built on the
23
+ MCP TypeScript SDK v2 (`@modelcontextprotocol/server`).
24
+
25
+ ## Requirements
26
+
27
+ - Node.js >= 20
28
+ - `fossil` on `PATH` (or set `FOSSIL_BIN`)
29
+
30
+ ## Build & run
31
+
32
+ ```bash
33
+ pnpm install
34
+ pnpm build
35
+
36
+ node dist/index.js -c b --repository /path/to/workspace # version control only
37
+ node dist/index.js -c ab --repository /path/to/workspace # admin + VCS
38
+ node dist/index.js -c de --repository /path/to/workspace # tickets + wiki
39
+ node dist/index.js --capability all --repository /path/to/workspace
40
+ ```
41
+
42
+ After `npm link` / a global install the same binary is on `PATH` as `fossil-scm`:
43
+
44
+ ```bash
45
+ fossil-scm -c ab --repository /path/to/workspace
46
+ ```
47
+
48
+ ### Selective enabling from an MCP client
49
+
50
+ Point several client entries at the same binary, each with its own letters. Every entry becomes an
51
+ independent MCP server process with its own tool list:
52
+
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "fossil-admin": {
57
+ "command": "node",
58
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "a", "--repository", "/path/to/workspace"]
59
+ },
60
+ "fossil-vcs": {
61
+ "command": "node",
62
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "b", "--repository", "/path/to/workspace"]
63
+ },
64
+ "fossil-forum": {
65
+ "command": "node",
66
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "c", "--repository", "/path/to/workspace"]
67
+ },
68
+ "fossil-tickets": {
69
+ "command": "node",
70
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "d", "--repository", "/path/to/workspace"]
71
+ },
72
+ "fossil-wiki": {
73
+ "command": "node",
74
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "e", "--repository", "/path/to/workspace"]
75
+ },
76
+ "fossil-chat": {
77
+ "command": "node",
78
+ "args": ["/abs/path/fossil-scm/dist/index.js", "-c", "f", "--repository", "/path/to/workspace"]
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ The name reported during the handshake follows the selection: `fossil-scm-a` … `fossil-scm-f` for a single
85
+ group, plain `fossil-scm` when several are combined.
86
+
87
+ ## Configuration
88
+
89
+ | CLI flag | Meaning |
90
+ | --- | --- |
91
+ | `-c, --capability LIST` | Capability letters: `a b c d e f`. Accepts `ab`, `a,b`, `a b`, repeated `-c` flags, or `all`. Default: `FOSSIL_CAPABILITIES`, else all |
92
+ | `--repository DIR` (also `--workspace`, `--cwd`, `-R`) | Default workspace for tool calls that omit `cwd` |
93
+ | `--verbose`, `-v` | Diagnostics on stderr (stdout is reserved for the protocol) |
94
+ | `--help`, `-h` | Usage, capability table and examples |
95
+
96
+ | Environment variable | Default | Meaning |
97
+ | --- | --- | --- |
98
+ | `FOSSIL_CAPABILITIES` | all | Default capability letters (same syntax as `--capability`) |
99
+ | `FOSSIL_WORKSPACE` / `FOSSIL_CWD` | cwd | Default workspace |
100
+ | `FOSSIL_BIN` | `fossil` | Fossil executable (full path works too) |
101
+ | `FOSSIL_TIMEOUT_MS` | `30000` | Timeout for regular commands |
102
+ | `FOSSIL_NETWORK_TIMEOUT_MS` | `600000` | Timeout for `clone`, `chat send`, `chat pull` |
103
+ | `FOSSIL_MAX_OUTPUT_CHARS` | `120000` | Output truncation threshold (head + tail are kept) |
104
+ | `FOSSIL_MAX_CAPTURE_BYTES` | `4194304` | Per-stream capture cap |
105
+ | `FOSSIL_REPOS_DIR` | `.fossil_repositories` | Sibling folder holding auto-derived `*.fossil` databases |
106
+
107
+ Repository databases resolve to `<parent-of-workspace>/.fossil_repositories/<name>.fossil` unless an
108
+ explicit path is passed to a tool.
109
+
110
+ ## Tools
111
+
112
+ **`a` Admin (5)** — `fossil_init`, `fossil_open`, `fossil_close`, `fossil_clone`, `fossil_settings`
113
+
114
+ **`b` VCS (20)** — `fossil_status`, `fossil_diff`, `fossil_cat`, `fossil_finfo`, `fossil_revert`,
115
+ `fossil_stash`, `fossil_tag`, `fossil_addremove`, `fossil_commit`, `fossil_add`, `fossil_rm`, `fossil_mv`,
116
+ `fossil_extras`, `fossil_clean`, `fossil_timeline`, `fossil_info`, `fossil_branch`, `fossil_merge`,
117
+ `fossil_update`, `fossil_undo`
118
+
119
+ **`c` Forum (3)** — `fossil_forum_list`, `fossil_forum_read`, `fossil_forum_search`
120
+
121
+ **`d` Tickets (3)** — `fossil_ticket_list`, `fossil_ticket_create`, `fossil_ticket_update`
122
+
123
+ **`e` Wiki (3)** — `fossil_wiki_ls`, `fossil_wiki_read`, `fossil_wiki_write`
124
+
125
+ **`f` Chat (4)** — `fossil_chat_url`, `fossil_chat_send`, `fossil_chat_pull`, `fossil_chat_read`
126
+
127
+ `fossil_init` / `fossil_open` (capability `a`) apply the recommended settings automatically
128
+ (`crlf-glob='*'`, `dotfiles=1`, `ignore-glob`, `binary-glob`) and create + stage `.editorconfig` when it is
129
+ missing. VCS and the content capabilities (`c`–`f`) expect an already opened check-out.
130
+
131
+ ### Capability notes
132
+
133
+ - **Forum is read-only.** Fossil 2.x has no CLI or JSON API to create forum posts — that lives in the web
134
+ UI — so the tools read the `F` artifacts Fossil stores in `event`/`blob` (via `fossil sql --readonly`)
135
+ and never write. `fossil_forum_read` accepts any post hash (prefixes work) and prints the whole thread.
136
+ - **Chat reads local data.** `fossil_chat_pull` downloads the chatroom into the clone (setup privilege
137
+ required on the server) or into an archive with `out`; `fossil_chat_read` reads either the clone or that
138
+ archive. `fossil_chat_send` needs a reachable remote and stored credentials.
139
+ - **SQL is always read-only and JSON-parsed.** `fossil sql --readonly -json` keeps values typed; SQL errors
140
+ are detected even though the sqlite shell exits with status 0.
141
+
142
+ ## What changed compared with the Python version
143
+
144
+ - **Selectable capabilities, one binary.** Tools are registered per capability (`src/capabilities.ts`) and
145
+ `--capability` takes a short letter list (`ab`, `cdf`, `all`) or `FOSSIL_CAPABILITIES`, so clients can
146
+ enable only the groups they want.
147
+ - **No interactive hangs.** `spawn` without a shell, stdin is always closed, `SIGTERM`→`SIGKILL` escalation,
148
+ and per-command timeouts. The commit flow still answers the "commit anyhow" prompt with `a`.
149
+ - **Fewer process spawns.** The four auto-config `fossil sql` calls collapse into one multi-statement
150
+ invocation; `fossil_status` runs `status` + `extra` in parallel; `fossil_wiki_write` picks `create` vs
151
+ `commit` from one page listing instead of failing a `commit` first.
152
+ - **Real error semantics.** Failures return `isError: true` with exit code, stdout/stderr and the executed
153
+ command, instead of a string the caller has to sniff for `"ERROR:"`.
154
+ - **Validated inputs.** Every tool declares a Zod schema (enums for sub-commands, integer limits, defaulted
155
+ flags), so the model gets accurate schemas and invalid arguments are rejected before spawning fossil.
156
+ - **Safer SQL.** Auto-config values are escaped instead of being interpolated raw, and query tools open the
157
+ repository with `--readonly`.
158
+ - **Bounded output.** Long command output is truncated head + tail, and per-stream capture is capped.
159
+ - **Structure + tests.** `src/config.ts` (env/flags), `src/core/*` (process runner, SQL, path resolution),
160
+ `src/tools/*` (tool groups), `src/capabilities.ts`, `src/server.ts`, `src/cli.ts`, `src/index.ts`.
161
+ `pnpm smoke` drives the real stdio interface for every capability letter and combination.
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ pnpm build # compile src -> dist
167
+ pnpm typecheck # tsc --noEmit (tsconfig.build.json)
168
+ pnpm smoke # end-to-end stdio test (each letter, combinations, env selection, bad input)
169
+ pnpm test # typecheck + build + smoke
170
+ pnpm pack # build the publishable tarball
171
+ ```
@@ -0,0 +1,33 @@
1
+ import type { McpServer } from '@modelcontextprotocol/server';
2
+ /**
3
+ * Every capability the package can expose, in display order.
4
+ * One consecutive single letter per group.
5
+ */
6
+ export declare const CAPABILITY_IDS: readonly ["a", "b", "c", "d", "e", "f"];
7
+ export type CapabilityId = (typeof CAPABILITY_IDS)[number];
8
+ export interface Capability {
9
+ id: CapabilityId;
10
+ /** Short human-readable name. */
11
+ title: string;
12
+ /** One-line description shown in the docs / help output. */
13
+ description: string;
14
+ /** Number of tools this capability contributes. */
15
+ toolCount: number;
16
+ register(server: McpServer): void;
17
+ }
18
+ /**
19
+ * The capability groups, one letter each:
20
+ *
21
+ * a = Admin (repository lifecycle) b = VCS (version control)
22
+ * c = Forum d = Tickets
23
+ * e = Wiki f = Chat
24
+ *
25
+ * `--capability b` exposes only the version-control tools, `--capability adf` is
26
+ * a three-group server, and so on.
27
+ */
28
+ export declare const CAPABILITIES: Record<CapabilityId, Capability>;
29
+ export declare function isCapabilityId(value: string): value is CapabilityId;
30
+ /** Every capability, in registry order. */
31
+ export declare function allCapabilities(): CapabilityId[];
32
+ /** Total tool count of the given capabilities. */
33
+ export declare function toolCountOf(ids: readonly CapabilityId[]): number;
@@ -0,0 +1,77 @@
1
+ import { registerAdminTools } from './tools/admin.js';
2
+ import { registerChatTools } from './tools/chat.js';
3
+ import { registerForumTools } from './tools/forum.js';
4
+ import { registerTicketTools } from './tools/tickets.js';
5
+ import { registerVersionControlTools } from './tools/version-control.js';
6
+ import { registerWikiTools } from './tools/wiki.js';
7
+ /**
8
+ * Every capability the package can expose, in display order.
9
+ * One consecutive single letter per group.
10
+ */
11
+ export const CAPABILITY_IDS = ['a', 'b', 'c', 'd', 'e', 'f'];
12
+ /**
13
+ * The capability groups, one letter each:
14
+ *
15
+ * a = Admin (repository lifecycle) b = VCS (version control)
16
+ * c = Forum d = Tickets
17
+ * e = Wiki f = Chat
18
+ *
19
+ * `--capability b` exposes only the version-control tools, `--capability adf` is
20
+ * a three-group server, and so on.
21
+ */
22
+ export const CAPABILITIES = {
23
+ a: {
24
+ id: 'a',
25
+ title: 'Admin',
26
+ description: 'Repository lifecycle (init/open/close/clone/settings)',
27
+ toolCount: 5,
28
+ register: registerAdminTools,
29
+ },
30
+ b: {
31
+ id: 'b',
32
+ title: 'VCS',
33
+ description: 'All version-control commands',
34
+ toolCount: 20,
35
+ register: registerVersionControlTools,
36
+ },
37
+ c: {
38
+ id: 'c',
39
+ title: 'Forum',
40
+ description: 'Read-only forum threads, posts and full-text search',
41
+ toolCount: 3,
42
+ register: registerForumTools,
43
+ },
44
+ d: {
45
+ id: 'd',
46
+ title: 'Tickets',
47
+ description: 'Ticket reports, creation and field updates',
48
+ toolCount: 3,
49
+ register: registerTicketTools,
50
+ },
51
+ e: {
52
+ id: 'e',
53
+ title: 'Wiki',
54
+ description: 'List, export and create/replace wiki pages',
55
+ toolCount: 3,
56
+ register: registerWikiTools,
57
+ },
58
+ f: {
59
+ id: 'f',
60
+ title: 'Chat',
61
+ description: 'Chatroom URL, sending messages, pulling and reading chat history',
62
+ toolCount: 4,
63
+ register: registerChatTools,
64
+ },
65
+ };
66
+ export function isCapabilityId(value) {
67
+ return CAPABILITY_IDS.includes(value);
68
+ }
69
+ /** Every capability, in registry order. */
70
+ export function allCapabilities() {
71
+ return [...CAPABILITY_IDS];
72
+ }
73
+ /** Total tool count of the given capabilities. */
74
+ export function toolCountOf(ids) {
75
+ return ids.reduce((total, id) => total + CAPABILITIES[id].toolCount, 0);
76
+ }
77
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAetE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqC;IAC5D,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,uDAAuD;QACpE,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,kBAAkB;KAC7B;IACD,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE,8BAA8B;QAC3C,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,2BAA2B;KACtC;IACD,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,qDAAqD;QAClE,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,kBAAkB;KAC7B;IACD,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,4CAA4C;QACzD,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,mBAAmB;KAC9B;IACD,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,4CAA4C;QACzD,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,iBAAiB;KAC5B;IACD,CAAC,EAAE;QACD,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,kEAAkE;QAC/E,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,iBAAiB;KAC5B;CACF,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAQ,cAAoC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC;AAC7B,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,WAAW,CAAC,GAA4B;IACtD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { type CapabilityId } from './capabilities.js';
2
+ /** Thrown for invalid command lines; callers print the message plus the help. */
3
+ export declare class UsageError extends Error {
4
+ }
5
+ export interface CliOptions {
6
+ cwd: string | undefined;
7
+ capabilities: CapabilityId[];
8
+ verbose: boolean;
9
+ help: boolean;
10
+ }
11
+ /**
12
+ * Parses the command line.
13
+ *
14
+ * `--capability` takes capability letters (one per group) and accepts `abf`,
15
+ * `a,b`, `a b`, repeated flags or `all`; when it is absent the list comes from
16
+ * `FOSSIL_CAPABILITIES` (or every capability).
17
+ * `--repository DIR` is consumed here so it can never reach the MCP transport.
18
+ */
19
+ export declare function parseArgs(argv: readonly string[], env?: NodeJS.ProcessEnv): CliOptions;
20
+ export declare function helpText(): string;
21
+ export interface RunOptions {
22
+ argv?: readonly string[] | undefined;
23
+ }
24
+ /**
25
+ * Parses the command line and serves MCP over stdio until the client hangs up.
26
+ */
27
+ export declare function run(options?: RunOptions): void;
package/dist/cli.js ADDED
@@ -0,0 +1,160 @@
1
+ import { serveStdio } from '@modelcontextprotocol/server/stdio';
2
+ import { CAPABILITIES, CAPABILITY_IDS, allCapabilities, isCapabilityId, toolCountOf, } from './capabilities.js';
3
+ import { SERVER_NAME, SERVER_VERSION, getDefaultCwd, setDefaultCwd } from './config.js';
4
+ import { createServer } from './server.js';
5
+ const VALUE_FLAGS = new Set(['--repository', '--workspace', '--cwd', '-R', '--capability', '-c']);
6
+ const CWD_FLAGS = new Set(['--repository', '--workspace', '--cwd', '-R']);
7
+ /** Thrown for invalid command lines; callers print the message plus the help. */
8
+ export class UsageError extends Error {
9
+ }
10
+ function addCapabilities(spec, selected) {
11
+ for (const token of spec.split(/[,\s]+/).map((part) => part.trim().toLowerCase())) {
12
+ if (!token)
13
+ continue;
14
+ if (token === 'all' || token === '*') {
15
+ for (const id of allCapabilities())
16
+ selected.add(id);
17
+ continue;
18
+ }
19
+ if (!isCapabilityId(token)) {
20
+ // Accept concatenated letters ('abf') as well as comma/space separated lists.
21
+ const letters = [...token];
22
+ const unknown = letters.filter((letter) => !isCapabilityId(letter));
23
+ if (unknown.length > 0) {
24
+ throw new UsageError(`unknown capability '${unknown[0]}'${token.length > 1 ? ` in '${token}'` : ''}. ` +
25
+ `Valid letters: ${CAPABILITY_IDS.map((id) => `${id}=${CAPABILITIES[id].title}`).join(', ')} (or 'all').`);
26
+ }
27
+ for (const letter of letters) {
28
+ if (isCapabilityId(letter))
29
+ selected.add(letter);
30
+ }
31
+ continue;
32
+ }
33
+ selected.add(token);
34
+ }
35
+ }
36
+ /**
37
+ * Parses the command line.
38
+ *
39
+ * `--capability` takes capability letters (one per group) and accepts `abf`,
40
+ * `a,b`, `a b`, repeated flags or `all`; when it is absent the list comes from
41
+ * `FOSSIL_CAPABILITIES` (or every capability).
42
+ * `--repository DIR` is consumed here so it can never reach the MCP transport.
43
+ */
44
+ export function parseArgs(argv, env = process.env) {
45
+ let cwd = env.FOSSIL_WORKSPACE?.trim() || env.FOSSIL_CWD?.trim() || undefined;
46
+ let verbose = false;
47
+ let help = false;
48
+ const selected = new Set();
49
+ let explicitCapabilities = false;
50
+ for (let index = 0; index < argv.length; index += 1) {
51
+ const arg = argv[index];
52
+ if (!arg)
53
+ continue;
54
+ if (arg === '--verbose' || arg === '-v') {
55
+ verbose = true;
56
+ continue;
57
+ }
58
+ if (arg === '--help' || arg === '-h') {
59
+ help = true;
60
+ continue;
61
+ }
62
+ const equalsIndex = arg.indexOf('=');
63
+ const flagName = equalsIndex > 0 ? arg.slice(0, equalsIndex) : arg;
64
+ if (!VALUE_FLAGS.has(flagName))
65
+ continue; // Unknown flags are ignored (MCP clients add their own).
66
+ const inlineValue = equalsIndex > 0 ? arg.slice(equalsIndex + 1) : undefined;
67
+ const value = inlineValue ?? argv[index + 1];
68
+ if (inlineValue === undefined)
69
+ index += 1;
70
+ if (value === undefined || value.startsWith('-')) {
71
+ throw new UsageError(`missing value for ${flagName}.`);
72
+ }
73
+ if (CWD_FLAGS.has(flagName)) {
74
+ cwd = value;
75
+ }
76
+ else {
77
+ explicitCapabilities = true;
78
+ addCapabilities(value, selected);
79
+ }
80
+ }
81
+ if (!explicitCapabilities) {
82
+ addCapabilities(env.FOSSIL_CAPABILITIES?.trim() || 'all', selected);
83
+ }
84
+ const capabilities = [...selected];
85
+ if (capabilities.length === 0) {
86
+ throw new UsageError("no capability selected; use --capability (e.g. 'ab') or FOSSIL_CAPABILITIES, or 'all'.");
87
+ }
88
+ return { cwd, capabilities, verbose, help };
89
+ }
90
+ export function helpText() {
91
+ const rows = CAPABILITY_IDS.map((id) => {
92
+ const capability = CAPABILITIES[id];
93
+ return ` ${id.padEnd(3)} ${capability.title.padEnd(8)} ${String(capability.toolCount).padStart(2)} tools ${capability.description}`;
94
+ });
95
+ return [
96
+ `${SERVER_NAME} MCP server v${SERVER_VERSION}`,
97
+ '',
98
+ `Usage: ${SERVER_NAME} [--capability LETTERS] [--repository DIR] [--verbose]`,
99
+ '',
100
+ 'Options:',
101
+ ' -c, --capability LIST Capability letters to enable: a b c d e f (one per group).',
102
+ " Accepts 'ab', 'a,b', 'a b', repeated -c flags, or 'all'.",
103
+ ' Default: FOSSIL_CAPABILITIES, or all capabilities when unset.',
104
+ ' Each selected group is served as its own MCP server instance.',
105
+ ' --repository DIR Default workspace for every tool call',
106
+ ' (aliases: --workspace, --cwd, -R)',
107
+ ' -v, --verbose Log diagnostics to stderr',
108
+ ' -h, --help Show this help',
109
+ '',
110
+ 'Capabilities:',
111
+ ...rows,
112
+ '',
113
+ 'Examples:',
114
+ ` ${SERVER_NAME} -c b # version control only (20 tools)`,
115
+ ` ${SERVER_NAME} -c ab # admin + VCS (25 tools)`,
116
+ ` ${SERVER_NAME} -c cdf # forum + tickets + chat (10 tools)`,
117
+ '',
118
+ 'Environment: FOSSIL_CAPABILITIES, FOSSIL_WORKSPACE, FOSSIL_CWD, FOSSIL_BIN,',
119
+ ' FOSSIL_TIMEOUT_MS, FOSSIL_NETWORK_TIMEOUT_MS, FOSSIL_MAX_OUTPUT_CHARS,',
120
+ ' FOSSIL_REPOS_DIR',
121
+ '',
122
+ ].join('\n');
123
+ }
124
+ function log(verbose, message) {
125
+ if (verbose)
126
+ process.stderr.write(`[${SERVER_NAME}] ${message}\n`);
127
+ }
128
+ /**
129
+ * Parses the command line and serves MCP over stdio until the client hangs up.
130
+ */
131
+ export function run(options = {}) {
132
+ let parsed;
133
+ try {
134
+ parsed = parseArgs(options.argv ?? process.argv.slice(2));
135
+ }
136
+ catch (error) {
137
+ if (!(error instanceof UsageError))
138
+ throw error;
139
+ process.stderr.write(`${SERVER_NAME}: ${error.message}\n\n${helpText()}`);
140
+ process.exitCode = 2;
141
+ return;
142
+ }
143
+ if (parsed.help) {
144
+ process.stderr.write(helpText());
145
+ return;
146
+ }
147
+ setDefaultCwd(parsed.cwd);
148
+ log(parsed.verbose, `starting v${SERVER_VERSION} | capabilities: ${parsed.capabilities.join(',')} (${toolCountOf(parsed.capabilities)} tools) ` +
149
+ `| workspace: ${getDefaultCwd() ?? process.cwd()}`);
150
+ const handle = serveStdio(() => createServer({ capabilities: parsed.capabilities }), {
151
+ onerror: (error) => process.stderr.write(`[${SERVER_NAME}] transport error: ${error.message}\n`),
152
+ });
153
+ const shutdown = (signal) => {
154
+ log(parsed.verbose, `${signal} received, shutting down`);
155
+ void handle.close().finally(() => process.exit(0));
156
+ };
157
+ process.once('SIGINT', () => shutdown('SIGINT'));
158
+ process.once('SIGTERM', () => shutdown('SIGTERM'));
159
+ }
160
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;AAClG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAE1E,iFAAiF;AACjF,MAAM,OAAO,UAAW,SAAQ,KAAK;CAAG;AASxC,SAAS,eAAe,CA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CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** Server/product name. The fossil *binary* stays `fossil` (see FOSSIL_BIN). */
2
+ export declare const SERVER_NAME = "fossil-scm";
3
+ export declare const SERVER_VERSION = "0.1.0";
4
+ export declare const SERVER_INSTRUCTIONS: string;
5
+ /**
6
+ * The Fossil executable. The command is named `fossil`; only the server/product
7
+ * name is written `fossil-scm`. Override with FOSSIL_BIN (e.g. a full path on Windows).
8
+ */
9
+ export declare const FOSSIL_BIN: string;
10
+ /** Timeout for regular commands. */
11
+ export declare const DEFAULT_TIMEOUT_MS: number;
12
+ /** Timeout for network-heavy commands (clone / sync). */
13
+ export declare const NETWORK_TIMEOUT_MS: number;
14
+ /** Output is truncated above this many characters before being returned to the model. */
15
+ export declare const MAX_OUTPUT_CHARS: number;
16
+ /** Hard cap on bytes buffered per stream (protects the process from runaway commands). */
17
+ export declare const MAX_CAPTURE_BYTES: number;
18
+ /** Name of the sibling directory that holds auto-derived repository databases. */
19
+ export declare const REPOS_DIR_NAME: string;
20
+ /** Settings applied automatically right after `init` / `open`. */
21
+ export declare const AUTO_SETTINGS: ReadonlyArray<readonly [name: string, value: string]>;
22
+ /** Content written to `.editorconfig` when a new check-out is opened. */
23
+ export declare const EDITORCONFIG_CONTENT: string;
24
+ /** Sets the workspace used when a tool call omits `cwd`. */
25
+ export declare function setDefaultCwd(dir: string | undefined): void;
26
+ /** Reads the configured default workspace, if any. */
27
+ export declare function getDefaultCwd(): string | undefined;
package/dist/config.js ADDED
@@ -0,0 +1,61 @@
1
+ import path from 'node:path';
2
+ const env = process.env;
3
+ function readPositiveInt(name, fallback) {
4
+ const raw = env[name]?.trim();
5
+ if (!raw)
6
+ return fallback;
7
+ const value = Number.parseInt(raw, 10);
8
+ return Number.isFinite(value) && value > 0 ? value : fallback;
9
+ }
10
+ /** Server/product name. The fossil *binary* stays `fossil` (see FOSSIL_BIN). */
11
+ export const SERVER_NAME = 'fossil-scm';
12
+ export const SERVER_VERSION = '0.1.0';
13
+ export const SERVER_INSTRUCTIONS = [
14
+ 'MCP server exposing 31 tools for complete Fossil SCM automation and integration',
15
+ '(repositories, check-outs, version control, tickets and wiki).',
16
+ 'Every tool accepts an optional `cwd` pointing at the check-out or workspace directory;',
17
+ 'when omitted the server default is used (set with --repository, FOSSIL_WORKSPACE or FOSSIL_CWD).',
18
+ 'Repository database files are auto-resolved to the sibling ".<repos dir>" folder when no explicit db_name is given.',
19
+ ].join(' ');
20
+ /**
21
+ * The Fossil executable. The command is named `fossil`; only the server/product
22
+ * name is written `fossil-scm`. Override with FOSSIL_BIN (e.g. a full path on Windows).
23
+ */
24
+ export const FOSSIL_BIN = env.FOSSIL_BIN?.trim() || 'fossil';
25
+ /** Timeout for regular commands. */
26
+ export const DEFAULT_TIMEOUT_MS = readPositiveInt('FOSSIL_TIMEOUT_MS', 30_000);
27
+ /** Timeout for network-heavy commands (clone / sync). */
28
+ export const NETWORK_TIMEOUT_MS = readPositiveInt('FOSSIL_NETWORK_TIMEOUT_MS', 600_000);
29
+ /** Output is truncated above this many characters before being returned to the model. */
30
+ export const MAX_OUTPUT_CHARS = readPositiveInt('FOSSIL_MAX_OUTPUT_CHARS', 120_000);
31
+ /** Hard cap on bytes buffered per stream (protects the process from runaway commands). */
32
+ export const MAX_CAPTURE_BYTES = readPositiveInt('FOSSIL_MAX_CAPTURE_BYTES', 4 * 1024 * 1024);
33
+ /** Name of the sibling directory that holds auto-derived repository databases. */
34
+ export const REPOS_DIR_NAME = env.FOSSIL_REPOS_DIR?.trim() || '.fossil_repositories';
35
+ /** Settings applied automatically right after `init` / `open`. */
36
+ export const AUTO_SETTINGS = [
37
+ ['crlf-glob', '*'],
38
+ ['dotfiles', '1'],
39
+ ['ignore-glob', 'deschide-ui-fossil.bat,Thumbs.db,.suo,.user,bin/,obj/,*__pycache__*,*.pyc,.venv/'],
40
+ ['binary-glob', '*.pcsave,*.png,*.jpg,*.zip,*.exe,*.dll,*.tar.gz'],
41
+ ];
42
+ /** Content written to `.editorconfig` when a new check-out is opened. */
43
+ export const EDITORCONFIG_CONTENT = [
44
+ '[*]',
45
+ 'end_of_line = lf',
46
+ 'insert_final_newline = true',
47
+ 'trim_trailing_whitespace = true',
48
+ '',
49
+ ].join('\n');
50
+ let defaultCwd = env.FOSSIL_WORKSPACE?.trim() || env.FOSSIL_CWD?.trim() || undefined;
51
+ /** Sets the workspace used when a tool call omits `cwd`. */
52
+ export function setDefaultCwd(dir) {
53
+ const trimmed = dir?.trim();
54
+ if (trimmed)
55
+ defaultCwd = path.resolve(trimmed);
56
+ }
57
+ /** Reads the configured default workspace, if any. */
58
+ export function getDefaultCwd() {
59
+ return defaultCwd;
60
+ }
61
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAExB,SAAS,eAAe,CAAC,IAAY,EAAE,QAAgB;IACrD,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG;QAAE,OAAO,QAAQ,CAAC;IAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,iFAAiF;IACjF,gEAAgE;IAChE,wFAAwF;IACxF,kGAAkG;IAClG,qHAAqH;CACt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