@githits/mcp 0.11.0 → 0.11.1
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/README.md +81 -2
- package/dist/client.d.ts +33 -15
- package/dist/client.js +1 -1
- package/dist/index.d.ts +27 -9
- package/dist/index.js +26 -40
- package/dist/shared/chunk-51x6tx02.js +2 -0
- package/dist/shared/chunk-62ejtp2e.js +16 -0
- package/dist/shared/chunk-mjxp4hpz.js +1314 -0
- package/dist/tools.d.ts +144 -0
- package/dist/tools.js +1 -0
- package/package.json +7 -1
- package/dist/shared/chunk-7xsjs2xx.js +0 -1317
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Annotation fields required by OpenAI's MCP marketplace validation. */
|
|
3
|
+
interface CompleteToolAnnotations {
|
|
4
|
+
title?: string;
|
|
5
|
+
readOnlyHint: boolean;
|
|
6
|
+
idempotentHint?: boolean;
|
|
7
|
+
openWorldHint: boolean;
|
|
8
|
+
destructiveHint: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface McpAuthActionContext {
|
|
11
|
+
authSource: unknown;
|
|
12
|
+
defaultAction: string;
|
|
13
|
+
}
|
|
14
|
+
type McpAuthAction = string | ((context: McpAuthActionContext) => string);
|
|
15
|
+
/** Host-selected message and action for terms-acceptance failures. */
|
|
16
|
+
interface ToolTermsRemediation {
|
|
17
|
+
message: string;
|
|
18
|
+
action: string;
|
|
19
|
+
}
|
|
20
|
+
/** Host-provided execution state shared by MCP and direct tool callers. */
|
|
21
|
+
interface ToolExecutionContext {
|
|
22
|
+
authAction?: McpAuthAction;
|
|
23
|
+
termsRemediation?: ToolTermsRemediation;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Standard result type for all MCP tools
|
|
28
|
+
*/
|
|
29
|
+
type ToolResult = {
|
|
30
|
+
content: Array<{
|
|
31
|
+
type: "text";
|
|
32
|
+
text: string;
|
|
33
|
+
}>;
|
|
34
|
+
isError?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** Transport-neutral callable tool handler receiving optional execution context. */
|
|
37
|
+
type ToolHandler<TArgs> = (args: TArgs, context?: ToolExecutionContext) => Promise<ToolResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Zod raw shape type (what MCP SDK expects)
|
|
40
|
+
*/
|
|
41
|
+
type ZodRawShape = {
|
|
42
|
+
[k: string]: z.ZodTypeAny;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Tool definition with metadata and handler
|
|
46
|
+
*/
|
|
47
|
+
interface ToolDefinition<
|
|
48
|
+
TArgs,
|
|
49
|
+
TSchema extends ZodRawShape = ZodRawShape
|
|
50
|
+
> {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
schema: TSchema;
|
|
54
|
+
annotations: CompleteToolAnnotations;
|
|
55
|
+
handler: ToolHandler<TArgs>;
|
|
56
|
+
}
|
|
57
|
+
/** Browser-standard options supplied to a callable tool execution. */
|
|
58
|
+
interface CallableToolExecutionOptions {
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
/** JSON Schema emitted for a callable tool's input. */
|
|
62
|
+
type CallableToolInputSchema = Record<string, unknown>;
|
|
63
|
+
/** Transport-neutral callable representation of a tool definition. */
|
|
64
|
+
interface CallableTool {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
inputSchema: CallableToolInputSchema;
|
|
68
|
+
annotations: CompleteToolAnnotations;
|
|
69
|
+
execute(input: unknown, options?: CallableToolExecutionOptions): Promise<ToolResult>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Adapt a Zod-backed tool definition to a browser-callable surface.
|
|
73
|
+
*
|
|
74
|
+
* Input is validated and defaulted before the original handler is invoked;
|
|
75
|
+
* only the optional abort signal crosses the callable execution boundary.
|
|
76
|
+
*/
|
|
77
|
+
declare function toCallableTool<
|
|
78
|
+
TArgs,
|
|
79
|
+
TSchema extends ZodRawShape
|
|
80
|
+
>(definition: ToolDefinition<TArgs, TSchema>): CallableTool;
|
|
81
|
+
interface GetExampleInput {
|
|
82
|
+
query: string;
|
|
83
|
+
language?: string;
|
|
84
|
+
license_mode?: "strict" | "yolo" | "custom";
|
|
85
|
+
format?: "json" | "text" | "text-v1";
|
|
86
|
+
}
|
|
87
|
+
/** Search parameters required by the browser-callable example tool. */
|
|
88
|
+
interface GetExampleSearchParams {
|
|
89
|
+
query: string;
|
|
90
|
+
language?: string;
|
|
91
|
+
licenseMode?: "strict" | "yolo" | "custom";
|
|
92
|
+
includeExplanation?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** Browser-standard request controls for example search. */
|
|
95
|
+
interface GetExampleRequestOptions {
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}
|
|
98
|
+
/** Minimal injected service contract used by the example tool. */
|
|
99
|
+
interface GetExampleService {
|
|
100
|
+
search(params: GetExampleSearchParams, options?: GetExampleRequestOptions): Promise<string>;
|
|
101
|
+
}
|
|
102
|
+
declare const schema: ZodRawShape;
|
|
103
|
+
declare function createGetExampleTool(service: GetExampleService): ToolDefinition<GetExampleInput, typeof schema>;
|
|
104
|
+
interface AuthenticationErrorInstance extends Error {
|
|
105
|
+
readonly source: "local" | "server";
|
|
106
|
+
}
|
|
107
|
+
interface AuthenticationErrorConstructor {
|
|
108
|
+
new (message?: string, source?: "local" | "server"): AuthenticationErrorInstance;
|
|
109
|
+
}
|
|
110
|
+
interface ApiRateLimitErrorInstance extends Error {
|
|
111
|
+
readonly status: 429;
|
|
112
|
+
readonly retryAfterSeconds: number | undefined;
|
|
113
|
+
}
|
|
114
|
+
interface ApiRateLimitErrorConstructor {
|
|
115
|
+
new (message?: string, retryAfterSeconds?: number): ApiRateLimitErrorInstance;
|
|
116
|
+
}
|
|
117
|
+
interface FetchTimeoutErrorInstance extends Error {
|
|
118
|
+
readonly timeoutMs: number;
|
|
119
|
+
}
|
|
120
|
+
interface FetchTimeoutErrorConstructor {
|
|
121
|
+
new (timeoutMs: number, options?: {
|
|
122
|
+
cause?: unknown;
|
|
123
|
+
}): FetchTimeoutErrorInstance;
|
|
124
|
+
}
|
|
125
|
+
interface TermsAcceptanceRequiredErrorInstance extends Error {
|
|
126
|
+
readonly code: "TERMS_ACCEPTANCE_REQUIRED";
|
|
127
|
+
readonly termsUrl: string;
|
|
128
|
+
readonly acceptanceUrl: string;
|
|
129
|
+
}
|
|
130
|
+
interface TermsAcceptanceRequiredErrorConstructor {
|
|
131
|
+
new (remediation?: {
|
|
132
|
+
termsUrl?: string;
|
|
133
|
+
acceptanceUrl?: string;
|
|
134
|
+
}): TermsAcceptanceRequiredErrorInstance;
|
|
135
|
+
}
|
|
136
|
+
/** Authentication failure raised by a GitHits service. */
|
|
137
|
+
declare const AuthenticationError: AuthenticationErrorConstructor;
|
|
138
|
+
/** Rate-limit failure raised by a GitHits service. */
|
|
139
|
+
declare const ApiRateLimitError: ApiRateLimitErrorConstructor;
|
|
140
|
+
/** Request deadline failure raised by a GitHits service. */
|
|
141
|
+
declare const FetchTimeoutError: FetchTimeoutErrorConstructor;
|
|
142
|
+
/** Terms gate raised by a GitHits service. */
|
|
143
|
+
declare const TermsAcceptanceRequiredError: TermsAcceptanceRequiredErrorConstructor;
|
|
144
|
+
export { ApiRateLimitError, AuthenticationError, CallableTool, CallableToolExecutionOptions, CallableToolInputSchema, CompleteToolAnnotations, FetchTimeoutError, GetExampleInput, GetExampleRequestOptions, GetExampleSearchParams, GetExampleService, TermsAcceptanceRequiredError, ToolResult, createGetExampleTool, toCallableTool };
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createGetExampleTool}from"./shared/chunk-62ejtp2e.js";import{ApiRateLimitError,AuthenticationError,FetchTimeoutError,TermsAcceptanceRequiredError}from"./shared/chunk-51x6tx02.js";import{z}from"zod";function toCallableTool(definition){const input=z.object(definition.schema);const inputSchema=z.toJSONSchema(input,{io:"input"});return{name:definition.name,description:definition.description,inputSchema,annotations:definition.annotations,execute:async(value,options)=>{const args=input.parse(value);const context={authAction:"Authenticate with GitHits, then retry.",...options?.signal?{signal:options.signal}:{}};return definition.handler(args,context)}}}var AuthenticationError2=AuthenticationError;var ApiRateLimitError2=ApiRateLimitError;var FetchTimeoutError2=FetchTimeoutError;var TermsAcceptanceRequiredError2=TermsAcceptanceRequiredError;export{ApiRateLimitError2 as ApiRateLimitError,AuthenticationError2 as AuthenticationError,FetchTimeoutError2 as FetchTimeoutError,TermsAcceptanceRequiredError2 as TermsAcceptanceRequiredError,createGetExampleTool,toCallableTool};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githits/mcp",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Reusable MCP server APIs and tools for GitHits",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"default": "./dist/smoke-test.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"./tools": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/tools.d.ts",
|
|
35
|
+
"default": "./dist/tools.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
32
38
|
"./package.json": "./package.json"
|
|
33
39
|
},
|
|
34
40
|
"scripts": {
|