@pipeshub-ai/mcp 2.1.0 → 2.2.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.
- package/README.md +90 -2
- package/bin/mcp-server.js +408 -74
- package/bin/mcp-server.js.map +19 -12
- package/esm/funcs/connectorGetRecordContent.d.ts +43 -0
- package/esm/funcs/connectorGetRecordContent.d.ts.map +1 -0
- package/esm/funcs/connectorGetRecordContent.js +114 -0
- package/esm/funcs/connectorGetRecordContent.js.map +1 -0
- package/esm/funcs/conversationsStreamConversation.js +1 -1
- package/esm/funcs/conversationsStreamConversation.js.map +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js.map +1 -1
- package/esm/hooks/registration.d.ts.map +1 -1
- package/esm/hooks/registration.js +2 -1
- package/esm/hooks/registration.js.map +1 -1
- package/esm/hooks/request-context.d.ts +10 -0
- package/esm/hooks/request-context.d.ts.map +1 -0
- package/esm/hooks/request-context.js +38 -0
- package/esm/hooks/request-context.js.map +1 -0
- package/esm/hooks/requestid.d.ts +5 -0
- package/esm/hooks/requestid.d.ts.map +1 -0
- package/esm/hooks/requestid.js +58 -0
- package/esm/hooks/requestid.js.map +1 -0
- package/esm/mcp-server/instructions.d.ts +1 -1
- package/esm/mcp-server/instructions.d.ts.map +1 -1
- package/esm/mcp-server/instructions.js +32 -9
- package/esm/mcp-server/instructions.js.map +1 -1
- package/esm/mcp-server/server.d.ts.map +1 -1
- package/esm/mcp-server/server.js +10 -3
- package/esm/mcp-server/server.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubChat.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubChat.js +8 -2
- package/esm/mcp-server/tools/pipeshubChat.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts +8 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts.map +1 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js +63 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js.map +1 -0
- package/esm/mcp-server/tools/pipeshubSearch.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubSearch.js +8 -4
- package/esm/mcp-server/tools/pipeshubSearch.js.map +1 -1
- package/esm/mcp-server/tools.d.ts.map +1 -1
- package/esm/mcp-server/tools.js +13 -1
- package/esm/mcp-server/tools.js.map +1 -1
- package/esm/models/getrecordcontentop.d.ts +6 -0
- package/esm/models/getrecordcontentop.d.ts.map +1 -0
- package/esm/models/getrecordcontentop.js +5 -0
- package/esm/models/getrecordcontentop.js.map +1 -0
- package/esm/tool-names.d.ts.map +1 -1
- package/esm/tool-names.js +6 -2
- package/esm/tool-names.js.map +1 -1
- package/package.json +2 -1
- package/src/funcs/connectorGetRecordContent.ts +179 -0
- package/src/funcs/conversationsStreamConversation.ts +1 -1
- package/src/funcs/userGroupsGetAllUserGroups.ts +1 -1
- package/src/hooks/registration.ts +2 -1
- package/src/hooks/request-context.ts +47 -0
- package/src/hooks/requestid.ts +62 -0
- package/src/mcp-server/instructions.ts +32 -9
- package/src/mcp-server/server.ts +11 -3
- package/src/mcp-server/tools/pipeshubChat.ts +8 -2
- package/src/mcp-server/tools/pipeshubGetRecordContent.ts +67 -0
- package/src/mcp-server/tools/pipeshubSearch.ts +8 -4
- package/src/mcp-server/tools.ts +14 -1
- package/src/models/getrecordcontentop.ts +11 -0
- package/src/tool-names.ts +6 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PipeshubCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
4
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
5
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
6
|
+
import { GetRecordContentRequest } from "../models/getrecordcontentop.js";
|
|
7
|
+
import { APIPromise } from "../types/async.js";
|
|
8
|
+
import { Result } from "../types/fp.js";
|
|
9
|
+
/**
|
|
10
|
+
* Get a record's full parsed content and metadata
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Retrieve the full parsed content and metadata of a single record —
|
|
14
|
+
* the same content PipesHub's own RAG/chat pipeline uses to answer
|
|
15
|
+
* questions, returned directly instead of via chat.
|
|
16
|
+
*
|
|
17
|
+
* **When to use this vs. the other record endpoints:**
|
|
18
|
+
* - `GET /knowledgeBase/record/{recordId}` returns metadata only
|
|
19
|
+
* (name, type, indexing status, size) — no content.
|
|
20
|
+
* - `GET /knowledgeBase/stream/record/{recordId}` returns the original,
|
|
21
|
+
* unparsed file bytes — use it to download/open the source file.
|
|
22
|
+
* - **This endpoint** returns the record's full parsed content as a
|
|
23
|
+
* single plain-text `content` string (a metadata header, then the
|
|
24
|
+
* block/table text in reading order) — use it when you need the
|
|
25
|
+
* record's actual textual/tabular content without downloading and
|
|
26
|
+
* re-parsing the original file yourself.
|
|
27
|
+
*
|
|
28
|
+
* **Typical flow:** obtain a `recordId` from a `pipeshub_search` hit or
|
|
29
|
+
* a chat citation's `recordId`, then call this endpoint to read the
|
|
30
|
+
* full content when the search snippet or citation excerpt isn't
|
|
31
|
+
* enough to answer the question.
|
|
32
|
+
*
|
|
33
|
+
* **Permission scoping:**
|
|
34
|
+
*
|
|
35
|
+
* The requesting user/token must have access to the record; access is
|
|
36
|
+
* verified via the knowledge graph before content is returned — a
|
|
37
|
+
* caller with a valid scope but no access to this specific record gets
|
|
38
|
+
* a `403`.
|
|
39
|
+
*
|
|
40
|
+
* If set, this operation will use either {@link Security.bearerAuth} or {@link Security.oauth2} from the global security.
|
|
41
|
+
*/
|
|
42
|
+
export declare function connectorGetRecordContent(client$: PipeshubCore, request: GetRecordContentRequest, options?: RequestOptions): APIPromise<Result<Response, APIError | SDKValidationError | UnexpectedClientError | InvalidRequestError | RequestAbortedError | RequestTimeoutError | ConnectionError>>;
|
|
43
|
+
//# sourceMappingURL=connectorGetRecordContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorGetRecordContent.d.ts","sourceRoot":"","sources":["../../src/funcs/connectorGetRecordContent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,QAAQ,EACN,QAAQ,GACR,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,CAClB,CACF,CAMA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from Speakeasy-generated connectorGetRecordContent.
|
|
3
|
+
*/
|
|
4
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
5
|
+
import { compactMap } from "../lib/primitives.js";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
8
|
+
import { pathToFunc } from "../lib/url.js";
|
|
9
|
+
import { GetRecordContentRequest$zodSchema, } from "../models/getrecordcontentop.js";
|
|
10
|
+
import { APIPromise } from "../types/async.js";
|
|
11
|
+
/**
|
|
12
|
+
* Get a record's full parsed content and metadata
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Retrieve the full parsed content and metadata of a single record —
|
|
16
|
+
* the same content PipesHub's own RAG/chat pipeline uses to answer
|
|
17
|
+
* questions, returned directly instead of via chat.
|
|
18
|
+
*
|
|
19
|
+
* **When to use this vs. the other record endpoints:**
|
|
20
|
+
* - `GET /knowledgeBase/record/{recordId}` returns metadata only
|
|
21
|
+
* (name, type, indexing status, size) — no content.
|
|
22
|
+
* - `GET /knowledgeBase/stream/record/{recordId}` returns the original,
|
|
23
|
+
* unparsed file bytes — use it to download/open the source file.
|
|
24
|
+
* - **This endpoint** returns the record's full parsed content as a
|
|
25
|
+
* single plain-text `content` string (a metadata header, then the
|
|
26
|
+
* block/table text in reading order) — use it when you need the
|
|
27
|
+
* record's actual textual/tabular content without downloading and
|
|
28
|
+
* re-parsing the original file yourself.
|
|
29
|
+
*
|
|
30
|
+
* **Typical flow:** obtain a `recordId` from a `pipeshub_search` hit or
|
|
31
|
+
* a chat citation's `recordId`, then call this endpoint to read the
|
|
32
|
+
* full content when the search snippet or citation excerpt isn't
|
|
33
|
+
* enough to answer the question.
|
|
34
|
+
*
|
|
35
|
+
* **Permission scoping:**
|
|
36
|
+
*
|
|
37
|
+
* The requesting user/token must have access to the record; access is
|
|
38
|
+
* verified via the knowledge graph before content is returned — a
|
|
39
|
+
* caller with a valid scope but no access to this specific record gets
|
|
40
|
+
* a `403`.
|
|
41
|
+
*
|
|
42
|
+
* If set, this operation will use either {@link Security.bearerAuth} or {@link Security.oauth2} from the global security.
|
|
43
|
+
*/
|
|
44
|
+
export function connectorGetRecordContent(client$, request, options) {
|
|
45
|
+
return new APIPromise($do(client$, request, options));
|
|
46
|
+
}
|
|
47
|
+
async function $do(client$, request, options) {
|
|
48
|
+
const parsed$ = safeParse(request, (value$) => GetRecordContentRequest$zodSchema.parse(value$), "Input validation failed");
|
|
49
|
+
if (!parsed$.ok) {
|
|
50
|
+
return [parsed$, { status: "invalid" }];
|
|
51
|
+
}
|
|
52
|
+
const payload$ = parsed$.value;
|
|
53
|
+
const body$ = null;
|
|
54
|
+
const pathParams$ = {
|
|
55
|
+
recordId: encodeSimple("recordId", payload$.recordId, {
|
|
56
|
+
explode: false,
|
|
57
|
+
charEncoding: "percent",
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
const path$ = pathToFunc("/connectors/record/{recordId}/content")(pathParams$);
|
|
61
|
+
const headers$ = new Headers(compactMap({
|
|
62
|
+
Accept: "application/json",
|
|
63
|
+
}));
|
|
64
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
65
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
66
|
+
const context = {
|
|
67
|
+
options: client$._options,
|
|
68
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
69
|
+
operationID: "getRecordContent",
|
|
70
|
+
oAuth2Scopes: ["connector:read"],
|
|
71
|
+
resolvedSecurity: requestSecurity,
|
|
72
|
+
securitySource: client$._options.security,
|
|
73
|
+
retryConfig: options?.retries
|
|
74
|
+
|| client$._options.retryConfig
|
|
75
|
+
|| { strategy: "none" },
|
|
76
|
+
retryCodes: options?.retryCodes || [
|
|
77
|
+
"429",
|
|
78
|
+
"500",
|
|
79
|
+
"502",
|
|
80
|
+
"503",
|
|
81
|
+
"504",
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
const requestRes = client$._createRequest(context, {
|
|
85
|
+
security: requestSecurity,
|
|
86
|
+
method: "GET",
|
|
87
|
+
baseURL: options?.serverURL,
|
|
88
|
+
path: path$,
|
|
89
|
+
headers: headers$,
|
|
90
|
+
body: body$,
|
|
91
|
+
userAgent: client$._options.userAgent,
|
|
92
|
+
timeoutMs: options?.timeoutMs || client$._options.timeoutMs
|
|
93
|
+
|| -1,
|
|
94
|
+
}, options);
|
|
95
|
+
if (!requestRes.ok) {
|
|
96
|
+
return [requestRes, { status: "invalid" }];
|
|
97
|
+
}
|
|
98
|
+
const req$ = requestRes.value;
|
|
99
|
+
const doResult = await client$._do(req$, {
|
|
100
|
+
context,
|
|
101
|
+
errorCodes: [],
|
|
102
|
+
retryConfig: context.retryConfig,
|
|
103
|
+
retryCodes: context.retryCodes,
|
|
104
|
+
});
|
|
105
|
+
if (!doResult.ok) {
|
|
106
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
107
|
+
}
|
|
108
|
+
return [doResult, {
|
|
109
|
+
status: "complete",
|
|
110
|
+
"request": req$,
|
|
111
|
+
response: doResult.value,
|
|
112
|
+
}];
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=connectorGetRecordContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorGetRecordContent.js","sourceRoot":"","sources":["../../src/funcs/connectorGetRecordContent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAU3C,OAAO,EAEL,iCAAiC,GAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAqB,EACrB,OAAgC,EAChC,OAAwB;IAaxB,OAAO,IAAI,UAAU,CAAC,GAAG,CACvB,OAAO,EACP,OAAO,EACP,OAAO,CACR,CAAC,C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AAK;SACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -30,7 +30,7 @@ async function $do(client$, request, options) {
|
|
|
30
30
|
options: client$._options,
|
|
31
31
|
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
32
32
|
operationID: "streamConversation",
|
|
33
|
-
oAuth2Scopes: ["conversation:
|
|
33
|
+
oAuth2Scopes: ["conversation:chat"],
|
|
34
34
|
resolvedSecurity: requestSecurity,
|
|
35
35
|
securitySource: client$._options.security,
|
|
36
36
|
retryConfig: options?.retries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversationsStreamConversation.js","sourceRoot":"","sources":["../../src/funcs/conversationsStreamConversation.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,uEAAuE;AACvE,0EAA0E;AAC1E,0CAA0C;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAEL,mCAAmC,GACpC,MAAM,wCAAwC,CAAC;AAUhD,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD,MAAM,UAAU,+BAA+B,CAC7C,OAAqB,EACrB,OAAkC,EAClC,OAAwB;IAaxB,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,KAAK,UAAU,GAAG,CAChB,OAAqB,EACrB,OAAkC,EAClC,OAAwB;IAgBxB,MAAM,OAAO,GAAG,SAAS,CACvB,OAAO,EACP,CAAC,MAAM,EAAE,EAAE,CAAC,mCAAmC,CAAC,KAAK,CAAC,MAAM,CAAC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AAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,CAAC,QAAQ,EAAE;YAChB,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,QAAQ,CAAC,KAAK;SACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -53,7 +53,7 @@ async function $do(client$, request, options) {
|
|
|
53
53
|
options: client$._options,
|
|
54
54
|
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
55
55
|
operationID: "getAllUserGroups",
|
|
56
|
-
oAuth2Scopes: [],
|
|
56
|
+
oAuth2Scopes: ["usergroup:read"],
|
|
57
57
|
resolvedSecurity: requestSecurity,
|
|
58
58
|
securitySource: client$._options.security,
|
|
59
59
|
retryConfig: options?.retries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userGroupsGetAllUserGroups.js","sourceRoot":"","sources":["../../src/funcs/userGroupsGetAllUserGroups.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAU3C,OAAO,EAEL,iCAAiC,GAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAqB,EACrB,OAA6C,EAC7C,OAAwB;IAaxB,OAAO,IAAI,UAAU,CAAC,GAAG,CACvB,OAAO,EACP,OAAO,EACP,OAAO,CACR,CAAC,CAAC;AACL,CA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B,OAAO,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;IAE9B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;QACvC,OAAO;QACP,UAAU,EAAE,EAAE;QACd,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,CAAC,QAAQ,EAAE;YAChB,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,QAAQ,CAAC,KAAK;SACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/hooks/registration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/hooks/registration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAQnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAKrC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { RequestIDHook } from "./requestid.js";
|
|
1
2
|
/*
|
|
2
3
|
* This file is only ever generated once on the first generation and then is free to be modified.
|
|
3
4
|
* Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
|
|
4
5
|
* in this file or in separate files in the hooks folder.
|
|
5
6
|
*/
|
|
6
|
-
// @ts-expect-error remove this line when you add your first hook and hooks is used
|
|
7
7
|
export function initHooks(hooks) {
|
|
8
8
|
// Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
|
|
9
9
|
// with an instance of a hook that implements that specific Hook interface
|
|
10
10
|
// Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
|
|
11
|
+
hooks.registerBeforeRequestHook(new RequestIDHook());
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=registration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/hooks/registration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AAEH,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;IAC5F,KAAK,CAAC,yBAAyB,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RequestContextStore {
|
|
2
|
+
random: string;
|
|
3
|
+
finalId?: string;
|
|
4
|
+
}
|
|
5
|
+
/** Bind a fresh request-id context for the remainder of the current async chain. */
|
|
6
|
+
export declare function bindNewRequestId(): void;
|
|
7
|
+
export declare function getRequestContextStore(): RequestContextStore | undefined;
|
|
8
|
+
/** One-off id for the rare case a backend call happens with no bound tool-call context. */
|
|
9
|
+
export declare function newRequestId(): string;
|
|
10
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/hooks/request-context.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,oFAAoF;AACpF,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,wBAAgB,sBAAsB,IAAI,mBAAmB,GAAG,SAAS,CAExE;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ambient per-tool-call request-id context (AsyncLocalStorage). Mirrors the
|
|
3
|
+
* pipeshub-ai backend's own request-context pattern (same header name,
|
|
4
|
+
* `x-request-id`) so a single id traces one MCP tool/resource/prompt
|
|
5
|
+
* invocation across every backend HTTP call it makes.
|
|
6
|
+
*
|
|
7
|
+
* `tools.ts` / `resources.ts` / `prompts.ts` are Speakeasy-generated and
|
|
8
|
+
* regenerated on every build, so there is no `next()`-style wrapper point to
|
|
9
|
+
* bind context around a call. Instead `bindNewRequestId` is called from the
|
|
10
|
+
* hand-written `getClient` closure in `server.ts`, which every generated
|
|
11
|
+
* dispatch site calls synchronously as the first thing before invoking a
|
|
12
|
+
* tool/resource/prompt handler — `enterWith` binds the store for the rest of
|
|
13
|
+
* that handler's execution (sync remainder + everything it awaits).
|
|
14
|
+
*
|
|
15
|
+
* The final id (`mcp-<userId>-<random>` or `mcp-<random>`) can't be composed
|
|
16
|
+
* at bind time — `getClient` only has a `PipeshubCore`, not yet a resolved
|
|
17
|
+
* `Authorization` header, and resolving security may be async (OAuth2)
|
|
18
|
+
* while `getClient` must stay sync (generated call sites pass its return
|
|
19
|
+
* value straight into a handler, never await it). So only the random suffix
|
|
20
|
+
* is fixed here; `requestid.ts`'s hook fills in `finalId` off the first
|
|
21
|
+
* outbound request's `Authorization` header and every later call in the
|
|
22
|
+
* same tool invocation reuses that cached value.
|
|
23
|
+
*/
|
|
24
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
25
|
+
import { nanoid } from "nanoid";
|
|
26
|
+
const storage = new AsyncLocalStorage();
|
|
27
|
+
/** Bind a fresh request-id context for the remainder of the current async chain. */
|
|
28
|
+
export function bindNewRequestId() {
|
|
29
|
+
storage.enterWith({ random: nanoid() });
|
|
30
|
+
}
|
|
31
|
+
export function getRequestContextStore() {
|
|
32
|
+
return storage.getStore();
|
|
33
|
+
}
|
|
34
|
+
/** One-off id for the rare case a backend call happens with no bound tool-call context. */
|
|
35
|
+
export function newRequestId() {
|
|
36
|
+
return `mcp-${nanoid()}`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/hooks/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAuB,CAAC;AAE7D,oFAAoF;AACpF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,MAAM,EAAE,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestid.d.ts","sourceRoot":"","sources":["../../src/hooks/requestid.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BrE,qBAAa,aAAc,YAAW,iBAAiB;IACrD,aAAa,CAAC,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;CAqBzE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Stamp an x-request-id trace header onto every outbound SDK request, reusing
|
|
3
|
+
* the id bound for the current MCP tool/resource/prompt call (see
|
|
4
|
+
* request-context.ts) so all backend calls from one invocation share it.
|
|
5
|
+
*
|
|
6
|
+
* Format mirrors the TypeScript SDK's own RequestIDHook: `mcp-<userId>-<random>`
|
|
7
|
+
* when the bearer JWT carries a userId claim, else `mcp-<random>`. The userId
|
|
8
|
+
* is only knowable once a request actually carries a resolved Authorization
|
|
9
|
+
* header, so it's decoded off the first outbound request of the tool call and
|
|
10
|
+
* cached on the bound context for every subsequent call to reuse verbatim.
|
|
11
|
+
*/
|
|
12
|
+
import { getRequestContextStore, newRequestId } from "./request-context.js";
|
|
13
|
+
const REQUEST_ID_HEADER = "x-request-id";
|
|
14
|
+
/** Decodes the JWT payload without verifying the signature. */
|
|
15
|
+
function decodeJwtPayload(token) {
|
|
16
|
+
try {
|
|
17
|
+
const base64Url = token.split(".")[1];
|
|
18
|
+
if (!base64Url)
|
|
19
|
+
return null;
|
|
20
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
21
|
+
const padded = base64 + "=".repeat((4 - (base64.length % 4)) % 4);
|
|
22
|
+
const claims = JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
23
|
+
return typeof claims === "object" && claims !== null ? claims : null;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function userIdFromRequest(request) {
|
|
30
|
+
const auth = request.headers.get("authorization") ?? "";
|
|
31
|
+
if (!auth.toLowerCase().startsWith("bearer "))
|
|
32
|
+
return null;
|
|
33
|
+
const token = auth.slice(7).trim();
|
|
34
|
+
const claims = decodeJwtPayload(token);
|
|
35
|
+
return claims?.["userId"] || null;
|
|
36
|
+
}
|
|
37
|
+
export class RequestIDHook {
|
|
38
|
+
beforeRequest(_hookCtx, request) {
|
|
39
|
+
if (request.headers.get(REQUEST_ID_HEADER)) {
|
|
40
|
+
return request;
|
|
41
|
+
}
|
|
42
|
+
const store = getRequestContextStore();
|
|
43
|
+
if (!store) {
|
|
44
|
+
// No bound tool-call context (shouldn't happen in practice).
|
|
45
|
+
request.headers.set(REQUEST_ID_HEADER, newRequestId());
|
|
46
|
+
return request;
|
|
47
|
+
}
|
|
48
|
+
if (!store.finalId) {
|
|
49
|
+
const userId = userIdFromRequest(request);
|
|
50
|
+
store.finalId = userId
|
|
51
|
+
? `mcp-${userId}-${store.random}`
|
|
52
|
+
: `mcp-${store.random}`;
|
|
53
|
+
}
|
|
54
|
+
request.headers.set(REQUEST_ID_HEADER, store.finalId);
|
|
55
|
+
return request;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=requestid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestid.js","sourceRoot":"","sources":["../../src/hooks/requestid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG5E,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,+DAA+D;AAC/D,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAC5B,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,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,IAAI,KAAK,CAAC,MAAM,EAAE;gBACjC,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PIPESHUB_INSTRUCTIONS = "# PipesHub MCP \u2014 instructions for the LLM\n\nPipesHub is the user's workplace AI platform. It indexes their documents,\nknowledge base content, and connector sources (Drive, Box, Confluence,\nSlack, Jira, Gmail, ...). When in doubt, the answer is in PipesHub.\n\n## Default tool: `pipeshub_chat`\n\n**Use `pipeshub_chat` for any question that could plausibly be answered\nby the user's PipesHub-indexed data
|
|
1
|
+
export declare const PIPESHUB_INSTRUCTIONS = "# PipesHub MCP \u2014 instructions for the LLM\n\nPipesHub is the user's workplace AI platform. It indexes their documents,\nknowledge base content, and connector sources (Drive, Box, Confluence,\nSlack, Jira, Gmail, ...). When in doubt, the answer is in PipesHub.\n\n## Full-document tasks: `pipeshub_search` \u2192 `pipeshub_get_record_content`\n\n`pipeshub_chat` answers from a handful of retrieved passages \u2014 it never\nreads a whole document. Whenever the task depends on a document's\nCOMPLETE content, fetch the document itself:\n\n1. `pipeshub_search` with the document's name / topic.\n2. Take the top hit's `recordId`.\n3. `pipeshub_get_record_content`, and answer from the returned content.\n\nTasks that need this path \u2014 anything where missing part of the document\ncould make the answer wrong:\n\n- Summarize / TL;DR / key points / takeaways / action items of a doc.\n- Extract or list ALL of something (dates, owners, requirements, ...).\n- Check whether / where a doc mentions something.\n- Translate, rewrite, outline, review, or reformat a doc.\n- Compare named docs (fetch each `recordId`).\n- Any question explicitly scoped to ONE named document \u2014 chat retrieval\n cannot be restricted to a single record.\n\n## Default tool: `pipeshub_chat`\n\n**Use `pipeshub_chat` for any question that could plausibly be answered\nby the user's PipesHub-indexed data** and is not a full-document task:\n\n- A question that may span several documents, or where you don't yet\n know which record holds the answer (e.g. \"what did Aashil say about\n onboarding?\").\n- Anything about company / org policies, processes, decisions, or\n history (e.g. \"what's our vacation policy?\", \"who owns the auth\n service?\").\n- Anything explicitly mentioning PipesHub itself, or its sources\n (Drive / Box / Confluence / Slack / Gmail / Jira / etc.) when the\n user has those connected.\n- Open-ended \"what do we know about X\" questions where the answer\n likely lives in the org's documents.\n\nDo NOT answer those from your own knowledge \u2014 `pipeshub_chat` grounds\nthe answer in the user's actual indexed content and returns citations\nthe user can verify.\n\n## When to use the other tools\n\n- `pipeshub_search` \u2014 locate a document by name or topic and resolve it\n to a `recordId`. To read or summarize one specific document, search,\n then pass the top hit's `recordId` to `pipeshub_get_record_content`.\n- `pipeshub_download_record` \u2014 when the user wants the actual file\n bytes (download, attach, open). Get the `recordId` either from\n citations on a prior `pipeshub_chat` response or from\n `pipeshub_search`.\n- `pipeshub_get_record_content` \u2014 when you need a record's full parsed\n content (returned as a single `content` string: metadata header plus\n the document's text) without downloading the original file. Prefer this\n over download when the question is about what the record says.\n- `pipeshub_directory` \u2014 people, groups, teams, and `whoami` lookups.\n Not for documents.\n- `pipeshub_sources` \u2014 call once at the start of a session to discover\n which connectors / KB / models are available, then cache the result.\n- `pipeshub_agents` \u2014 list the org's configured **agents** (specialized\n assistants with their own prompt, tools, and knowledge scope).\n\n## Agents\n\nSome orgs configure **agents** for specific jobs (e.g. a Slack messenger, a\nJira ticket creator, a Salesforce CRM updater). To run a turn against an\nagent, call `pipeshub_chat` with its `agentId` (from `pipeshub_agents`)\n\u2014 optionally with an agent `chatMode` (`auto` by default, or `quick` /\n`verification` / `deep`). Keep passing the same `agentId` plus the\nreturned `conversationId` on follow-up turns.\n\n**When to route to an agent vs plain chat:**\n- The user names a system/action that maps to an agent (e.g. \"post to\n Slack\", \"create a Jira ticket\", \"update the Salesforce deal\") \u2192 call\n `pipeshub_agents`, pick the matching agent, and use it.\n- Plain question about the org's knowledge or the public web \u2192 just use\n `pipeshub_chat` (no `agentId`) with `internal_search` or `web_search`.\n\n**If you are unsure which agent or route fits the request**, call\n`pipeshub_agents` FIRST and read the returned names/descriptions, then\neither pick the best match or present the list to the user and let them\nchoose. Do NOT guess an agent blindly, and do NOT refuse \u2014 list the agents\nand decide from real data. The list may be empty (no agents configured),\nin which case fall back to plain `pipeshub_chat`.\n\n## Conversation lifecycle\n\n`pipeshub_chat` is a single tool that handles both starting and\ncontinuing conversations (plain or with an `agentId`). On the first turn\nomit `conversationId`; on every subsequent turn pass back the\n`conversationId` returned by the previous call (along with the same\n`agentId` if you used one). Server-side context is preserved \u2014 do NOT\nreplay prior messages. Only start a fresh conversation when the user\nexplicitly asks to clear context.\n";
|
|
2
2
|
//# sourceMappingURL=instructions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/mcp-server/instructions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/mcp-server/instructions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,q+JAoGjC,CAAC"}
|
|
@@ -8,14 +8,35 @@ PipesHub is the user's workplace AI platform. It indexes their documents,
|
|
|
8
8
|
knowledge base content, and connector sources (Drive, Box, Confluence,
|
|
9
9
|
Slack, Jira, Gmail, ...). When in doubt, the answer is in PipesHub.
|
|
10
10
|
|
|
11
|
+
## Full-document tasks: \`pipeshub_search\` → \`pipeshub_get_record_content\`
|
|
12
|
+
|
|
13
|
+
\`pipeshub_chat\` answers from a handful of retrieved passages — it never
|
|
14
|
+
reads a whole document. Whenever the task depends on a document's
|
|
15
|
+
COMPLETE content, fetch the document itself:
|
|
16
|
+
|
|
17
|
+
1. \`pipeshub_search\` with the document's name / topic.
|
|
18
|
+
2. Take the top hit's \`recordId\`.
|
|
19
|
+
3. \`pipeshub_get_record_content\`, and answer from the returned content.
|
|
20
|
+
|
|
21
|
+
Tasks that need this path — anything where missing part of the document
|
|
22
|
+
could make the answer wrong:
|
|
23
|
+
|
|
24
|
+
- Summarize / TL;DR / key points / takeaways / action items of a doc.
|
|
25
|
+
- Extract or list ALL of something (dates, owners, requirements, ...).
|
|
26
|
+
- Check whether / where a doc mentions something.
|
|
27
|
+
- Translate, rewrite, outline, review, or reformat a doc.
|
|
28
|
+
- Compare named docs (fetch each \`recordId\`).
|
|
29
|
+
- Any question explicitly scoped to ONE named document — chat retrieval
|
|
30
|
+
cannot be restricted to a single record.
|
|
31
|
+
|
|
11
32
|
## Default tool: \`pipeshub_chat\`
|
|
12
33
|
|
|
13
34
|
**Use \`pipeshub_chat\` for any question that could plausibly be answered
|
|
14
|
-
by the user's PipesHub-indexed data
|
|
35
|
+
by the user's PipesHub-indexed data** and is not a full-document task:
|
|
15
36
|
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
- A question that may span several documents, or where you don't yet
|
|
38
|
+
know which record holds the answer (e.g. "what did Aashil say about
|
|
39
|
+
onboarding?").
|
|
19
40
|
- Anything about company / org policies, processes, decisions, or
|
|
20
41
|
history (e.g. "what's our vacation policy?", "who owns the auth
|
|
21
42
|
service?").
|
|
@@ -31,15 +52,17 @@ the user can verify.
|
|
|
31
52
|
|
|
32
53
|
## When to use the other tools
|
|
33
54
|
|
|
34
|
-
- \`pipeshub_search\` —
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
the doc say?" use \`pipeshub_chat\` instead — it does the retrieval
|
|
38
|
-
internally.
|
|
55
|
+
- \`pipeshub_search\` — locate a document by name or topic and resolve it
|
|
56
|
+
to a \`recordId\`. To read or summarize one specific document, search,
|
|
57
|
+
then pass the top hit's \`recordId\` to \`pipeshub_get_record_content\`.
|
|
39
58
|
- \`pipeshub_download_record\` — when the user wants the actual file
|
|
40
59
|
bytes (download, attach, open). Get the \`recordId\` either from
|
|
41
60
|
citations on a prior \`pipeshub_chat\` response or from
|
|
42
61
|
\`pipeshub_search\`.
|
|
62
|
+
- \`pipeshub_get_record_content\` — when you need a record's full parsed
|
|
63
|
+
content (returned as a single \`content\` string: metadata header plus
|
|
64
|
+
the document's text) without downloading the original file. Prefer this
|
|
65
|
+
over download when the question is about what the record says.
|
|
43
66
|
- \`pipeshub_directory\` — people, groups, teams, and \`whoami\` lookups.
|
|
44
67
|
Not for documents.
|
|
45
68
|
- \`pipeshub_sources\` — call once at the start of a session to discover
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/mcp-server/instructions.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sEAAsE;AACtE,sEAAsE;AACtE,gEAAgE;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/mcp-server/instructions.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sEAAsE;AACtE,sEAAsE;AACtE,gEAAgE;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAWvC,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IAChD,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CACvD;;;;;;EA2EA"}
|
package/esm/mcp-server/server.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { PIPESHUB_INSTRUCTIONS } from "./instructions.js";
|
|
3
3
|
import { PipeshubCore } from "../core.js";
|
|
4
|
+
import { bindNewRequestId } from "../hooks/request-context.js";
|
|
4
5
|
import { createRegisterPrompt } from "./prompts.js";
|
|
5
6
|
import { createRegisterResource, createRegisterResourceTemplate, } from "./resources.js";
|
|
6
7
|
import { createRegisterTool, registerDynamicTools } from "./tools.js";
|
|
7
8
|
import { tool$pipeshubChat } from "./tools/pipeshubChat.js";
|
|
8
9
|
import { tool$pipeshubSearch } from "./tools/pipeshubSearch.js";
|
|
9
10
|
import { tool$pipeshubDownloadRecord } from "./tools/pipeshubDownloadRecord.js";
|
|
11
|
+
import { tool$pipeshubGetRecordContent } from "./tools/pipeshubGetRecordContent.js";
|
|
10
12
|
import { tool$pipeshubDirectory } from "./tools/pipeshubDirectory.js";
|
|
11
13
|
import { tool$pipeshubSources } from "./tools/pipeshubSources.js";
|
|
12
14
|
import { tool$pipeshubAgents } from "./tools/pipeshubAgents.js";
|
|
@@ -18,7 +20,7 @@ export function createMCPServer(deps) {
|
|
|
18
20
|
}, {
|
|
19
21
|
instructions: PIPESHUB_INSTRUCTIONS,
|
|
20
22
|
});
|
|
21
|
-
const
|
|
23
|
+
const resolveClient = deps.getSDK || (() => new PipeshubCore({
|
|
22
24
|
security: deps.security,
|
|
23
25
|
serverURL: deps.serverURL,
|
|
24
26
|
serverIdx: deps.serverIdx,
|
|
@@ -31,6 +33,10 @@ export function createMCPServer(deps) {
|
|
|
31
33
|
}
|
|
32
34
|
: undefined,
|
|
33
35
|
}));
|
|
36
|
+
const getClient = () => {
|
|
37
|
+
bindNewRequestId();
|
|
38
|
+
return resolveClient();
|
|
39
|
+
};
|
|
34
40
|
const scopes = new Set(deps.scopes);
|
|
35
41
|
const allowedTools = deps.allowedTools && new Set(deps.allowedTools);
|
|
36
42
|
const [tool, tools, toolMap] = createRegisterTool(deps.logger, server, getClient, scopes, allowedTools, deps.dynamic);
|
|
@@ -44,8 +50,9 @@ export function createMCPServer(deps) {
|
|
|
44
50
|
tool(tool$pipeshubChat); // 2. ask questions (start + continue)
|
|
45
51
|
tool(tool$pipeshubSearch); // 3. resolve filename → recordId
|
|
46
52
|
tool(tool$pipeshubDownloadRecord); // 4. fetch a document by id
|
|
47
|
-
tool(tool$
|
|
48
|
-
tool(tool$
|
|
53
|
+
tool(tool$pipeshubGetRecordContent); // 5. fetch a record's parsed content
|
|
54
|
+
tool(tool$pipeshubDirectory); // 6. people / groups / teams / whoami
|
|
55
|
+
tool(tool$pipeshubAgents); // 7. discover org agents
|
|
49
56
|
// Curated prompt: user-invokable tool-routing guidance.
|
|
50
57
|
prompt(prompt$pipeshubAssistant);
|
|
51
58
|
if (deps.dynamic) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,MAAM,UAAU,eAAe,CAAC,IAU/B;IACC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,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;AAKzB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAoB7C,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;CA2CT,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"pipeshubChat.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/pipeshubChat.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAoB7C,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;CA2CT,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,OAAO,IAAI,CAsMzD,CAAC"}
|
|
@@ -72,6 +72,9 @@ the user asks about their documents, files, knowledge base, company policies,
|
|
|
72
72
|
or anything that could plausibly be answered by content in their PipesHub-indexed
|
|
73
73
|
sources (Drive, Box, Confluence, Slack, Gmail, Jira, the org's KB, ...).
|
|
74
74
|
Grounds the answer in the user's actual data and returns citations.
|
|
75
|
+
Answers come from a few retrieved passages, not whole documents — for
|
|
76
|
+
any task needing a document's full content, use
|
|
77
|
+
\`pipeshub_get_record_content\` instead.
|
|
75
78
|
|
|
76
79
|
**Web search** (\`chatMode: "web_search"\`): Use when the user asks about
|
|
77
80
|
current events, public information, or anything unlikely to be in the org's
|
|
@@ -79,8 +82,11 @@ internal knowledge base. Pass \`chatMode: "web_search"\` and this tool will
|
|
|
79
82
|
search the public web instead.
|
|
80
83
|
|
|
81
84
|
**When to pick this over other tools:**
|
|
82
|
-
- "
|
|
83
|
-
|
|
85
|
+
- "Summarize <doc>" / "key points of <doc>" / "what does <document> say
|
|
86
|
+
about X?" → NOT this tool. Use \`pipeshub_search\` →
|
|
87
|
+
\`pipeshub_get_record_content\`: answering for a specific document
|
|
88
|
+
requires its full content, and chat only sees a few retrieved
|
|
89
|
+
passages, never the whole document.
|
|
84
90
|
- "What's our policy on Y?" → \`pipeshub_chat\` (internal_search)
|
|
85
91
|
- "What's in the news about Z?" → \`pipeshub_chat\` (web_search)
|
|
86
92
|
- "What is the latest version of <library>?" → \`pipeshub_chat\` (web_search)
|