@foundation0/git 1.3.1 → 1.3.2

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/mcp/README.md CHANGED
@@ -12,11 +12,13 @@ Each tool is addressed by the full API path (`repo.issue.create`, `search.issues
12
12
  - `args`: array of positional string arguments
13
13
  - `options`: object for request body/query/header customisation
14
14
 
15
- Tool results are returned as a compact envelope by default:
16
-
17
- ```json
18
- { "ok": true, "data": { "...": "..." }, "meta": { "status": 200 } }
19
- ```
15
+ Tool results are returned as a compact envelope by default:
16
+
17
+ ```json
18
+ { "ok": true, "data": { "...": "..." }, "meta": { "status": 200 } }
19
+ ```
20
+
21
+ The default mode now returns a trimmed response body (empty/noisy nested fields removed, common entities compacted). To get the original upstream body, pass `full: true`.
20
22
 
21
23
  If the upstream git API returns `{ ok: false }` or an HTTP status `>= 400`, the MCP tool call is marked as an error (`isError: true`) and a typed error envelope is returned:
22
24
 
@@ -24,7 +26,8 @@ If the upstream git API returns `{ ok: false }` or an HTTP status `>= 400`, the
24
26
  { "ok": false, "error": { "code": "HTTP_NOT_FOUND", "status": 404, "message": "HTTP 404", "retryable": false }, "meta": { "status": 404 } }
25
27
  ```
26
28
 
27
- To include the full debug payload (mapping/request/response headers), pass `format: "debug"` (either top-level or in `options`).
29
+ To include the full debug payload (mapping/request/response headers), pass `format: "debug"` (either top-level or in `options`).
30
+ To return unfiltered API response data, pass `full: true` (either top-level or in `options`).
28
31
 
29
32
  Use the `batch` tool to run multiple calls in one request. It is the preferred mode when you want to issue multiple MCP calls because it executes them in parallel and returns a combined response.
30
33
 
@@ -115,21 +118,33 @@ console.log(result.isError)
115
118
  console.log(result.text)
116
119
  ```
117
120
 
118
- `callByPath` converts positional args and options for convenience. `call` can also be used with the raw tool arguments object:
121
+ `callByPath` converts positional args and options for convenience. `call` can also be used with the raw tool arguments object:
119
122
 
120
123
  ```ts
121
124
  await client.call('repo.issue.create', {
122
125
  options: {
123
126
  data: { title: 'Issue from MCP' },
124
127
  },
125
- })
126
- ```
128
+ })
129
+ ```
130
+
131
+ `callByPath` also accepts an optional fourth `controls` argument (`format`, `fields`, `validateOnly`, `full`):
132
+
133
+ ```ts
134
+ await client.callByPath('repo.pr.view', [525], {}, { full: true })
135
+ ```
127
136
 
128
137
  To return a debug payload for a specific call:
129
138
 
130
139
  ```ts
131
- await client.call('repo.issue.list', { format: 'debug' })
132
- ```
140
+ await client.call('repo.issue.list', { format: 'debug' })
141
+ ```
142
+
143
+ To bypass compact mode and return the full upstream payload:
144
+
145
+ ```ts
146
+ await client.call('repo.pr.view', { number: 525, full: true })
147
+ ```
133
148
 
134
149
  ## Using with MCP-compatible agents
135
150
 
package/mcp/src/client.ts CHANGED
@@ -46,11 +46,15 @@ export interface GitMcpClientOptions {
46
46
  version?: string
47
47
  }
48
48
 
49
- export interface GitMcpCallArgs {
50
- args?: unknown[]
51
- options?: Record<string, unknown>
52
- [key: string]: unknown
53
- }
49
+ export interface GitMcpCallArgs {
50
+ args?: unknown[]
51
+ options?: Record<string, unknown>
52
+ format?: 'terse' | 'debug'
53
+ fields?: string[] | string
54
+ validateOnly?: boolean
55
+ full?: boolean
56
+ [key: string]: unknown
57
+ }
54
58
 
55
59
  export type GitMcpCallResponse = {
56
60
  isError: boolean
@@ -132,15 +136,20 @@ export class GitMcpClient {
132
136
  }
133
137
  }
134
138
 
135
- public async callByPath(
136
- path: string,
137
- methodArgs: unknown[] = [],
138
- methodOptions: Record<string, unknown> = {},
139
- ): Promise<GitMcpCallResponse> {
140
- const args = { args: methodArgs.map((value) => String(value)), options: methodOptions }
141
- return this.call(path, args)
142
- }
143
- }
139
+ public async callByPath(
140
+ path: string,
141
+ methodArgs: unknown[] = [],
142
+ methodOptions: Record<string, unknown> = {},
143
+ controls: Pick<GitMcpCallArgs, 'format' | 'fields' | 'validateOnly' | 'full'> = {},
144
+ ): Promise<GitMcpCallResponse> {
145
+ const args = {
146
+ args: methodArgs.map((value) => String(value)),
147
+ options: methodOptions,
148
+ ...controls,
149
+ }
150
+ return this.call(path, args)
151
+ }
152
+ }
144
153
 
145
154
  export const createGitMcpClient = (options: GitMcpClientOptions = {}): GitMcpClient => {
146
155
  return new GitMcpClient(options)