@http-forge/core 0.4.8 → 0.5.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 +14 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +174 -174
- package/dist/index.mjs +175 -175
- package/dist/infrastructure/config/config.interface.d.ts +22 -0
- package/dist/infrastructure/config/index.d.ts +1 -1
- package/dist/infrastructure/script/interfaces.d.ts +6 -1
- package/dist/infrastructure/script/script-factories.d.ts +56 -6
- package/dist/infrastructure/script/script-utils.d.ts +14 -0
- package/dist/runtime/mcp-tool-name.d.ts +25 -7
- package/dist/runtime/mcp-tool-schemas.d.ts +22 -0
- package/package.json +1 -1
|
@@ -85,6 +85,18 @@ export interface McpCorsConfig {
|
|
|
85
85
|
/** Origins allowed to access the MCP server (defaults to localhost variants) */
|
|
86
86
|
allowedOrigins: string[];
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* How the MCP server shapes its `tools/list` response.
|
|
90
|
+
*
|
|
91
|
+
* - `flat`: one tool per request/folder/collection/suite (most discoverable;
|
|
92
|
+
* best for AI agents, but the list grows with the number of requests).
|
|
93
|
+
* - `drilldown`: a small fixed set of generic tools (`list_collections`,
|
|
94
|
+
* `list_requests`, `run_request`, `run_folder`, `run_collection`, `run_suite`)
|
|
95
|
+
* whose arguments select the target. The list stays tiny regardless of scale.
|
|
96
|
+
* - `auto`: use `flat` until the number of request tools would exceed
|
|
97
|
+
* `drilldownThreshold`, then switch to `drilldown`.
|
|
98
|
+
*/
|
|
99
|
+
export type McpToolMode = 'flat' | 'drilldown' | 'auto';
|
|
88
100
|
/**
|
|
89
101
|
* MCP Server project-level configuration (stored in http-forge.config.json)
|
|
90
102
|
*
|
|
@@ -111,6 +123,16 @@ export interface McpConfig {
|
|
|
111
123
|
* collection or suite call. Prevents accidental runaway executions.
|
|
112
124
|
*/
|
|
113
125
|
maxRequestsPerCall: number;
|
|
126
|
+
/**
|
|
127
|
+
* Tool-list shape. Defaults to `flat`. Use `drilldown` or `auto` for very
|
|
128
|
+
* large workspaces to keep `tools/list` small and AI-friendly.
|
|
129
|
+
*/
|
|
130
|
+
toolMode: McpToolMode;
|
|
131
|
+
/**
|
|
132
|
+
* When `toolMode` is `auto`, switch to drilldown once the number of request
|
|
133
|
+
* tools would exceed this count. Ignored for `flat` and `drilldown`.
|
|
134
|
+
*/
|
|
135
|
+
drilldownThreshold: number;
|
|
114
136
|
/** CORS configuration */
|
|
115
137
|
cors: McpCorsConfig;
|
|
116
138
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Config Services
|
|
3
3
|
*/
|
|
4
|
-
export type { EnvironmentsConfig, HttpForgeConfig, IConfigService, McpConfig, McpCorsConfig, ProxyConfig, RequestConfig, RestClientExportConfig, RunnerConfig, ScriptsConfig, StorageConfig } from './config.interface';
|
|
4
|
+
export type { EnvironmentsConfig, HttpForgeConfig, IConfigService, McpConfig, McpCorsConfig, McpToolMode, ProxyConfig, RequestConfig, RestClientExportConfig, RunnerConfig, ScriptsConfig, StorageConfig } from './config.interface';
|
|
5
5
|
export { CONFIG_FILES, DEFAULT_CONFIG, ROOT_DIRECTORIES } from './default-config';
|
|
6
6
|
export { ConfigService } from './config-service';
|
|
@@ -51,7 +51,12 @@ export interface ResponseContext {
|
|
|
51
51
|
headers: Record<string, string>;
|
|
52
52
|
/** Raw response body string (Postman-compatible). Parse on demand via response.json(). */
|
|
53
53
|
body: any;
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Response cookies parsed from Set-Cookie headers, including metadata such as
|
|
56
|
+
* domain, path, expires, maxAge, httpOnly, secure and sameSite. Exposed to
|
|
57
|
+
* scripts as the Postman-compatible `pm.response.cookies` CookieList.
|
|
58
|
+
*/
|
|
59
|
+
cookies?: Cookie[];
|
|
55
60
|
responseTime?: number;
|
|
56
61
|
responseSize?: number;
|
|
57
62
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Single Responsibility: Create objects used in script execution contexts
|
|
5
5
|
* Open/Closed: New factory methods can be added without modifying existing ones
|
|
6
6
|
*/
|
|
7
|
+
import { Cookie } from '../cookie/interfaces';
|
|
7
8
|
import { ResponseContext } from './interfaces';
|
|
8
9
|
/**
|
|
9
10
|
* Minimal, dependency-free JSON Schema validator.
|
|
@@ -18,22 +19,24 @@ export declare function validateJsonSchema(data: any, schema: any, path?: string
|
|
|
18
19
|
* Response object interface for script context
|
|
19
20
|
*/
|
|
20
21
|
export interface ScriptResponse {
|
|
21
|
-
status
|
|
22
|
+
/** Reason phrase string (Postman parity, e.g. "OK"). Use `code` for the numeric status. */
|
|
23
|
+
status: string;
|
|
22
24
|
code: number;
|
|
23
25
|
statusText: string;
|
|
24
26
|
headers: Record<string, string>;
|
|
25
27
|
/** Raw response body string (Postman-compatible). Use json() to parse, text() for the string. */
|
|
26
28
|
body: any;
|
|
27
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Postman-compatible CookieList. Use `cookies.get(name)` for the value string,
|
|
31
|
+
* `cookies.one(name)` for the full cookie object (domain, path, expires, maxAge,
|
|
32
|
+
* httpOnly, secure, sameSite), `cookies.has(name)`, `cookies.toObject()`, or iterate.
|
|
33
|
+
*/
|
|
34
|
+
cookies: CookieList;
|
|
28
35
|
responseTime?: number;
|
|
29
36
|
responseSize?: number;
|
|
30
|
-
getHeader(name: string): string | undefined;
|
|
31
|
-
getCookie(name: string): string | undefined;
|
|
32
37
|
reason(): string;
|
|
33
38
|
json(): any;
|
|
34
39
|
text(): string;
|
|
35
|
-
cookie(name: string): string | undefined;
|
|
36
|
-
hasCookie(name: string): boolean;
|
|
37
40
|
to: ResponseAssertions;
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
@@ -56,6 +59,53 @@ export interface ResponseAssertions {
|
|
|
56
59
|
readonly serverError: any;
|
|
57
60
|
};
|
|
58
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Postman-compatible Cookie object (a single entry of a CookieList).
|
|
64
|
+
*
|
|
65
|
+
* Coerces to its value string via valueOf()/toString() so `cookie == 'abc'`
|
|
66
|
+
* and template literals work, while still exposing the full metadata.
|
|
67
|
+
*/
|
|
68
|
+
export interface PostmanCookie {
|
|
69
|
+
name: string;
|
|
70
|
+
value: string;
|
|
71
|
+
domain?: string;
|
|
72
|
+
path?: string;
|
|
73
|
+
expires?: string;
|
|
74
|
+
maxAge?: number;
|
|
75
|
+
httpOnly: boolean;
|
|
76
|
+
secure: boolean;
|
|
77
|
+
/** True when the cookie has neither Expires nor Max-Age (cleared at session end). */
|
|
78
|
+
session: boolean;
|
|
79
|
+
hostOnly: boolean;
|
|
80
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
81
|
+
valueOf(): string;
|
|
82
|
+
toString(): string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Postman-compatible CookieList (a PropertyList of cookies).
|
|
86
|
+
*
|
|
87
|
+
* Mirrors the Postman SDK API:
|
|
88
|
+
* - `cookies.get(name)` → the cookie VALUE string (or undefined)
|
|
89
|
+
* - `cookies.one(name)` → the full cookie OBJECT (or undefined)
|
|
90
|
+
* - `cookies.has(name)` → boolean
|
|
91
|
+
* - `cookies.toObject()` → plain `{ name: value }` map
|
|
92
|
+
* It is also a real array, so `forEach`, `map`, `filter`, `find`, numeric
|
|
93
|
+
* indexing and `for...of` iteration all work over the cookie objects.
|
|
94
|
+
*/
|
|
95
|
+
export interface CookieList extends Array<PostmanCookie> {
|
|
96
|
+
get(name: string): string | undefined;
|
|
97
|
+
one(name: string): PostmanCookie | undefined;
|
|
98
|
+
has(name: string): boolean;
|
|
99
|
+
toObject(): Record<string, string>;
|
|
100
|
+
all(): PostmanCookie[];
|
|
101
|
+
each(cb: (cookie: PostmanCookie) => void): void;
|
|
102
|
+
count(): number;
|
|
103
|
+
idx(index: number): PostmanCookie | undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create a Postman-compatible CookieList from parsed cookies.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createCookieList(cookies: Cookie[]): CookieList;
|
|
59
109
|
/**
|
|
60
110
|
* Create response object with helper methods for script context
|
|
61
111
|
* Provides Postman-compatible response API
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* These are stateless helper functions with no side effects
|
|
6
6
|
*/
|
|
7
7
|
import { TestAssertion } from '../../types/types';
|
|
8
|
+
import { Cookie } from '../cookie/interfaces';
|
|
8
9
|
/**
|
|
9
10
|
* Console message structure for script output
|
|
10
11
|
*/
|
|
@@ -47,3 +48,16 @@ export declare function createTestFunction(assertions: TestAssertion[]): any;
|
|
|
47
48
|
* Converts multi-value headers (string[]) to comma-separated strings
|
|
48
49
|
*/
|
|
49
50
|
export declare function normalizeHeaders(headers: Record<string, string | string[]>): Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Build rich response cookie metadata for the legacy Postman sandbox.
|
|
53
|
+
*
|
|
54
|
+
* Prefers parsing the raw `Set-Cookie` response headers via CookieUtils, which
|
|
55
|
+
* captures full metadata (domain, path, expires, maxAge, httpOnly, secure,
|
|
56
|
+
* sameSite). Falls back to the HTTP client's already-parsed cookie array when
|
|
57
|
+
* the raw headers are unavailable (e.g. some fetch-based transports).
|
|
58
|
+
*
|
|
59
|
+
* @param headers - Raw response headers (Set-Cookie may be a string[])
|
|
60
|
+
* @param parsedCookies - Cookie objects already parsed by the HTTP client
|
|
61
|
+
* @param requestUrl - URL used to derive the default cookie domain
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseResponseCookieDetails(headers: Record<string, string | string[]> | undefined, parsedCookies: any[] | undefined, requestUrl?: string): Cookie[];
|
|
@@ -6,19 +6,37 @@
|
|
|
6
6
|
* tool name like `request__<collectionId>__<requestId>` can exceed 240 chars
|
|
7
7
|
* and be rejected by the model provider.
|
|
8
8
|
*
|
|
9
|
-
* To
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* To balance discoverability and the length limit we embed the raw ID verbatim
|
|
10
|
+
* when it is a safe, short segment (so names stay human-readable), and otherwise
|
|
11
|
+
* substitute a deterministic short hash token. A whole-name length guard re-hashes
|
|
12
|
+
* every segment when the assembled name would still be too long. A call resolves
|
|
13
|
+
* back to the real entity by matching the segment against the current
|
|
14
|
+
* collections / requests / folders / suites (raw equality OR hash), so both raw
|
|
15
|
+
* and hashed names — including previously-listed long names — keep working.
|
|
13
16
|
*
|
|
14
17
|
* IDs are NOT changed — they remain the stable external references used by
|
|
15
18
|
* suites, result filenames, and history. Only the tool *name* is shortened.
|
|
16
19
|
*
|
|
17
20
|
* The model selects a tool by its *description* (which still contains the
|
|
18
|
-
* human-readable names), so
|
|
21
|
+
* human-readable names), so the exact tool name does not affect tool choice.
|
|
19
22
|
*/
|
|
20
|
-
/**
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Deterministic short token for an ID or folder path (12 hex chars).
|
|
25
|
+
* @param value The value to be hashed.
|
|
26
|
+
* @param maxLen The maximum length of the raw segment before appending the hash.
|
|
27
|
+
* @returns A string combining the truncated value and its hash.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mcpToolToken(value: string, maxLen?: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Return `value` verbatim when it is a safe, short raw segment (discoverable),
|
|
32
|
+
* otherwise its deterministic hash token. Either way the result never contains
|
|
33
|
+
* `__`, so tool-name parsing by `split('__')` stays unambiguous.
|
|
34
|
+
*
|
|
35
|
+
* @param value The value to be used as a tool segment.
|
|
36
|
+
* @param maxLen The maximum length of the raw segment before falling back to a hash token.
|
|
37
|
+
* @returns A string representing the tool segment, either raw or hashed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mcpToolSegment(value: string, maxLen?: number): string;
|
|
22
40
|
export type McpToolKind = 'request' | 'collection' | 'folder' | 'suite';
|
|
23
41
|
export declare function buildRequestToolName(prefix: string, collectionId: string, requestId: string): string;
|
|
24
42
|
export declare function buildCollectionToolName(prefix: string, collectionId: string): string;
|
|
@@ -168,3 +168,25 @@ export declare const SUITE_INPUT_SCHEMA: {
|
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
170
|
};
|
|
171
|
+
/** Stable names of the generic drill-down tools (prefix is added separately). */
|
|
172
|
+
export declare const GENERIC_TOOL_NAMES: {
|
|
173
|
+
readonly listCollections: "list_collections";
|
|
174
|
+
readonly listRequests: "list_requests";
|
|
175
|
+
readonly runRequest: "run_request";
|
|
176
|
+
readonly runFolder: "run_folder";
|
|
177
|
+
readonly runCollection: "run_collection";
|
|
178
|
+
readonly runSuite: "run_suite";
|
|
179
|
+
};
|
|
180
|
+
export type GenericToolName = (typeof GENERIC_TOOL_NAMES)[keyof typeof GENERIC_TOOL_NAMES];
|
|
181
|
+
interface GenericToolDef {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
inputSchema: Record<string, unknown>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Build the generic drill-down tool definitions. `collectionLabels` and
|
|
188
|
+
* `suiteLabels` are the human-readable names injected as enums so the model can
|
|
189
|
+
* only choose targets that exist.
|
|
190
|
+
*/
|
|
191
|
+
export declare function buildGenericTools(prefix: string, collectionLabels: readonly string[], suiteLabels: readonly string[]): GenericToolDef[];
|
|
192
|
+
export {};
|
package/package.json
CHANGED