@jinshuju/mcp 0.0.0-stage → 0.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/dist/config.js ADDED
@@ -0,0 +1,44 @@
1
+ export const DEFAULTS = {
2
+ apiBaseUrl: 'https://jinshuju.net/api/v1',
3
+ authServer: 'https://account.jinshuju.net',
4
+ publicUrls: [],
5
+ maxResultChars: 120_000,
6
+ tokenCacheTtlMs: 5 * 60_000,
7
+ timeoutMs: 60_000,
8
+ posthogHost: 'https://us.i.posthog.com',
9
+ collectIntent: true
10
+ };
11
+ function int(value, fallback) {
12
+ const n = Number(value);
13
+ return Number.isFinite(n) && n > 0 ? n : fallback;
14
+ }
15
+ function bool(value, fallback) {
16
+ const v = (value ?? '').trim().toLowerCase();
17
+ if (['1', 'true', 'yes', 'on'].includes(v))
18
+ return true;
19
+ if (['0', 'false', 'no', 'off'].includes(v))
20
+ return false;
21
+ return fallback;
22
+ }
23
+ /** JINSHUJU_MCP_PUBLIC_URL: several comma-separated addresses, with trailing slashes and empty items removed. */
24
+ export function publicUrlsFromEnv(value) {
25
+ return (value ?? '')
26
+ .split(',')
27
+ .map((u) => u.trim().replace(/\/$/, ''))
28
+ .filter(Boolean);
29
+ }
30
+ /** Reads the configuration from environment variables; keys carry the JINSHUJU_ prefix, as in @jinshuju/cli. */
31
+ export function configFromEnv(env = process.env) {
32
+ return {
33
+ apiBaseUrl: (env.JINSHUJU_API_BASE_URL ?? DEFAULTS.apiBaseUrl).replace(/\/$/, ''),
34
+ authServer: (env.JINSHUJU_AUTH_HOST ?? DEFAULTS.authServer).replace(/\/$/, ''),
35
+ publicUrls: publicUrlsFromEnv(env.JINSHUJU_MCP_PUBLIC_URL),
36
+ maxResultChars: int(env.JINSHUJU_MCP_MAX_RESULT_CHARS, DEFAULTS.maxResultChars),
37
+ tokenCacheTtlMs: int(env.JINSHUJU_MCP_TOKEN_CACHE_TTL_MS, DEFAULTS.tokenCacheTtlMs),
38
+ timeoutMs: int(env.JINSHUJU_MCP_TIMEOUT_MS, DEFAULTS.timeoutMs),
39
+ posthogApiKey: env.POSTHOG_API_KEY?.trim() || undefined,
40
+ posthogHost: (env.POSTHOG_HOST?.trim() || DEFAULTS.posthogHost).replace(/\/$/, ''),
41
+ collectIntent: bool(env.JINSHUJU_MCP_COLLECT_INTENT, DEFAULTS.collectIntent)
42
+ };
43
+ }
44
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The credential source interface and its simplest implementation.
3
+ *
4
+ * HTTP mode: every request brings its own Bearer, and the credential is that string (StaticCredential).
5
+ * The local credential for stdio mode (~/.jinshuju/config.json, with refresh) lives in cli-credential.ts,
6
+ * which depends on node:fs; this file uses no Node API, so the Worker bundle pulls in no node: modules.
7
+ */
8
+ export interface Credential {
9
+ /** The access token currently usable */
10
+ token(): Promise<string>;
11
+ /** The API answered 401: drop the cache / try to renew. Returns true when a new credential was obtained and one retry is worthwhile. */
12
+ invalidate(): Promise<boolean>;
13
+ /** For descriptions such as auth status */
14
+ describe(): string;
15
+ }
16
+ export declare class StaticCredential implements Credential {
17
+ private readonly value;
18
+ private readonly source;
19
+ constructor(value: string, source?: string);
20
+ token(): Promise<string>;
21
+ invalidate(): Promise<boolean>;
22
+ describe(): string;
23
+ }
24
+ export declare class MissingCredentialError extends Error {
25
+ constructor();
26
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The credential source interface and its simplest implementation.
3
+ *
4
+ * HTTP mode: every request brings its own Bearer, and the credential is that string (StaticCredential).
5
+ * The local credential for stdio mode (~/.jinshuju/config.json, with refresh) lives in cli-credential.ts,
6
+ * which depends on node:fs; this file uses no Node API, so the Worker bundle pulls in no node: modules.
7
+ */
8
+ export class StaticCredential {
9
+ value;
10
+ source;
11
+ constructor(value, source = 'bearer') {
12
+ this.value = value;
13
+ this.source = source;
14
+ }
15
+ async token() {
16
+ return this.value;
17
+ }
18
+ async invalidate() {
19
+ return false;
20
+ }
21
+ describe() {
22
+ return `access token (${this.source})`;
23
+ }
24
+ }
25
+ export class MissingCredentialError extends Error {
26
+ constructor() {
27
+ super('No Jinshuju credential available. Set JINSHUJU_ACCESS_TOKEN=<personal or account access token>, ' +
28
+ 'or log in first with `npx @jinshuju/cli auth login` (this server reuses ~/.jinshuju/config.json).');
29
+ this.name = 'MissingCredentialError';
30
+ }
31
+ }
32
+ //# sourceMappingURL=credential.js.map
@@ -0,0 +1,113 @@
1
+ {
2
+ "generatedFrom": {
3
+ "title": "Jinshuju API v1",
4
+ "version": "1.0",
5
+ "sha256": "54912d2240cc55de"
6
+ },
7
+ "baseUrl": "https://jinshuju.net/api/v1",
8
+ "toolCount": 60,
9
+ "operationCount": 123,
10
+ "tools": {
11
+ "list_forms": "listForms",
12
+ "get_form": "getForm",
13
+ "create_form": "createForm",
14
+ "edit_form": "updateForm",
15
+ "copy_form": "copyForm",
16
+ "move_form": "moveFormToFolder",
17
+ "list_form_cooperators": "listFormCooperators",
18
+ "get_field_rules": "listFieldRules",
19
+ "check_field_data": "checkFormFieldData",
20
+ "preview_field_type_change": "previewFormFieldTypeChange",
21
+ "edit_theme": "updateFormTheme",
22
+ "list_entries": "listEntries",
23
+ "get_entry": "getEntry",
24
+ "create_entry": "createEntry",
25
+ "update_entry": "updateEntry",
26
+ "delete_entry": "deleteEntry",
27
+ "create_entries": "createEntriesBatch",
28
+ "patch_entries": "patchEntriesBatch",
29
+ "aggregate_entries": "aggregateEntries",
30
+ "get_form_data_summary": "summarizeEntries",
31
+ "search_entries_in_forms": "searchEntriesAcrossForms",
32
+ "list_form_entry_stats": "getEntryStats",
33
+ "list_my_submitted_forms": "listMyFilledForms",
34
+ "list_my_submitted_entries": "listMySubmittedEntries",
35
+ "search_my_submitted_entries": "searchMySubmittedEntries",
36
+ "import_entries_from_file": "createEntryImport",
37
+ "list_entry_comments": "listEntryComments",
38
+ "create_entry_comment": "createEntryComment",
39
+ "update_entry_comment": "updateEntryComment",
40
+ "delete_entry_comment": "deleteEntryComment",
41
+ "list_form_views": "listFormViews",
42
+ "get_form_view": "getFormView",
43
+ "create_form_view": "createFormView",
44
+ "edit_form_view": "updateFormView",
45
+ "delete_form_view": "deleteFormView",
46
+ "list_form_view_entries": "listFormViewEntries",
47
+ "list_tables": "listTables",
48
+ "get_table": "getTable",
49
+ "create_table": "createTable",
50
+ "edit_table": "updateTable",
51
+ "move_table": "moveTableToFolder",
52
+ "list_opensearch_queries": "listOpensearchQueries",
53
+ "get_opensearch_query": "getOpensearchQuery",
54
+ "create_opensearch_query": "createOpensearchQuery",
55
+ "edit_opensearch_query": "updateOpensearchQuery",
56
+ "get_opensearch_field_suggestions": "listOpensearchQuerySuggestions",
57
+ "list_folders": "listFolders",
58
+ "create_folder": "createFolder",
59
+ "get_current_user": "getCurrentUser",
60
+ "get_current_billing_account": "getBillingAccount",
61
+ "list_account_users": "listBillingAccountUsers",
62
+ "upload_entry_attachment": "uploadEntryAttachment",
63
+ "upload_form_image": "uploadFormImage",
64
+ "upload_import_file": "uploadImportFile",
65
+ "edit_field_rules": "updateForm",
66
+ "create_exam_form": "createForm+updateExamSetting",
67
+ "edit_exam_form": "updateForm+updateExamSetting",
68
+ "create_evaluation_form": "createForm+updateEvaluationSetting",
69
+ "edit_evaluation_form": "updateForm+updateEvaluationSetting",
70
+ "count_entries": "countEntries+countEntriesAcrossForms"
71
+ },
72
+ "pointerSchemas": [
73
+ "BillingAccount",
74
+ "EntryData",
75
+ "EvaluationSetting",
76
+ "EvaluationSettingInput",
77
+ "FieldDefinition",
78
+ "FieldInput",
79
+ "FieldUpdateInput",
80
+ "FormSetting",
81
+ "FormSettingInput",
82
+ "FormSettingWriteInput",
83
+ "FormTheme",
84
+ "FormView",
85
+ "FormViewInput",
86
+ "GoodsItemInput",
87
+ "OpensearchQuery",
88
+ "OpensearchQueryInput",
89
+ "ThemeInput",
90
+ "TradeMerchant"
91
+ ],
92
+ "omitSchemas": [
93
+ "FormCreateConstraints"
94
+ ],
95
+ "tags": {
96
+ "Forms": "Forms: list, structure, create and edit, plus field display rules, cooperators, copy, move and other related operations.",
97
+ "Form Settings": "Form settings: submission settings, access policy, Webhook, theme, closing rules, exam / evaluation scene settings.",
98
+ "Entries": "Form entries: list, query, create, update, delete and batch operations.",
99
+ "Tables": "Tables (kind=table): structure and entries; field types are limited to the column types tables support.",
100
+ "Views": "Form / table views (view filters, sort, column configuration) and reading entries through a view.",
101
+ "Comments": "Entry comments.",
102
+ "Fill": "Fill links: read the fill page (`/f/`, `/v/`) as a submitter and submit entries through it.",
103
+ "OpenSearch": "Public queries.",
104
+ "Folders": "Folders.",
105
+ "Predefined Choices Sets": "Predefined choice sets.",
106
+ "Templates": "Using templates.",
107
+ "Contacts": "Contacts.",
108
+ "Account": "Current user and account: members, e-invoices, payment history, SMS signature review status.",
109
+ "Trade": "小金商户: merchant and onboarding progress, payment orders, transaction statistics, refunds and payouts.",
110
+ "Uploads": "Uploading attachments, form images and import files.",
111
+ "Utilities": "Utility endpoints."
112
+ }
113
+ }