@josephyan/qingflow-cli 0.2.0-beta.1000
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 +31 -0
- package/docs/local-agent-install.md +309 -0
- package/entry_point.py +13 -0
- package/npm/bin/qingflow.mjs +5 -0
- package/npm/lib/runtime.mjs +346 -0
- package/npm/scripts/postinstall.mjs +16 -0
- package/package.json +34 -0
- package/pyproject.toml +67 -0
- package/qingflow +15 -0
- package/src/qingflow_mcp/__init__.py +37 -0
- package/src/qingflow_mcp/__main__.py +5 -0
- package/src/qingflow_mcp/backend_client.py +649 -0
- package/src/qingflow_mcp/builder_facade/__init__.py +3 -0
- package/src/qingflow_mcp/builder_facade/models.py +1846 -0
- package/src/qingflow_mcp/builder_facade/service.py +16502 -0
- package/src/qingflow_mcp/cli/__init__.py +1 -0
- package/src/qingflow_mcp/cli/commands/__init__.py +18 -0
- package/src/qingflow_mcp/cli/commands/app.py +40 -0
- package/src/qingflow_mcp/cli/commands/auth.py +112 -0
- package/src/qingflow_mcp/cli/commands/builder.py +539 -0
- package/src/qingflow_mcp/cli/commands/chart.py +18 -0
- package/src/qingflow_mcp/cli/commands/common.py +62 -0
- package/src/qingflow_mcp/cli/commands/imports.py +96 -0
- package/src/qingflow_mcp/cli/commands/portal.py +25 -0
- package/src/qingflow_mcp/cli/commands/record.py +331 -0
- package/src/qingflow_mcp/cli/commands/repo.py +80 -0
- package/src/qingflow_mcp/cli/commands/task.py +141 -0
- package/src/qingflow_mcp/cli/commands/view.py +18 -0
- package/src/qingflow_mcp/cli/commands/workspace.py +110 -0
- package/src/qingflow_mcp/cli/context.py +60 -0
- package/src/qingflow_mcp/cli/formatters.py +573 -0
- package/src/qingflow_mcp/cli/json_io.py +50 -0
- package/src/qingflow_mcp/cli/main.py +186 -0
- package/src/qingflow_mcp/cli/qingflow_login.py +116 -0
- package/src/qingflow_mcp/cli/terminal_ui.py +173 -0
- package/src/qingflow_mcp/config.py +407 -0
- package/src/qingflow_mcp/errors.py +66 -0
- package/src/qingflow_mcp/id_utils.py +49 -0
- package/src/qingflow_mcp/import_store.py +121 -0
- package/src/qingflow_mcp/json_types.py +18 -0
- package/src/qingflow_mcp/list_type_labels.py +76 -0
- package/src/qingflow_mcp/public_surface.py +243 -0
- package/src/qingflow_mcp/repository_store.py +71 -0
- package/src/qingflow_mcp/response_trim.py +841 -0
- package/src/qingflow_mcp/server.py +216 -0
- package/src/qingflow_mcp/server_app_builder.py +543 -0
- package/src/qingflow_mcp/server_app_user.py +386 -0
- package/src/qingflow_mcp/session_store.py +369 -0
- package/src/qingflow_mcp/solution/__init__.py +6 -0
- package/src/qingflow_mcp/solution/build_assembly_store.py +181 -0
- package/src/qingflow_mcp/solution/compiler/__init__.py +282 -0
- package/src/qingflow_mcp/solution/compiler/chart_compiler.py +96 -0
- package/src/qingflow_mcp/solution/compiler/form_compiler.py +495 -0
- package/src/qingflow_mcp/solution/compiler/icon_utils.py +187 -0
- package/src/qingflow_mcp/solution/compiler/navigation_compiler.py +57 -0
- package/src/qingflow_mcp/solution/compiler/package_compiler.py +19 -0
- package/src/qingflow_mcp/solution/compiler/portal_compiler.py +60 -0
- package/src/qingflow_mcp/solution/compiler/view_compiler.py +51 -0
- package/src/qingflow_mcp/solution/compiler/workflow_compiler.py +173 -0
- package/src/qingflow_mcp/solution/design_session.py +222 -0
- package/src/qingflow_mcp/solution/design_store.py +100 -0
- package/src/qingflow_mcp/solution/executor.py +2398 -0
- package/src/qingflow_mcp/solution/normalizer.py +23 -0
- package/src/qingflow_mcp/solution/requirements_builder.py +536 -0
- package/src/qingflow_mcp/solution/run_store.py +244 -0
- package/src/qingflow_mcp/solution/spec_models.py +855 -0
- package/src/qingflow_mcp/tools/__init__.py +1 -0
- package/src/qingflow_mcp/tools/ai_builder_tools.py +3449 -0
- package/src/qingflow_mcp/tools/app_tools.py +926 -0
- package/src/qingflow_mcp/tools/approval_tools.py +1062 -0
- package/src/qingflow_mcp/tools/auth_tools.py +1133 -0
- package/src/qingflow_mcp/tools/base.py +281 -0
- package/src/qingflow_mcp/tools/code_block_tools.py +777 -0
- package/src/qingflow_mcp/tools/custom_button_tools.py +202 -0
- package/src/qingflow_mcp/tools/directory_tools.py +675 -0
- package/src/qingflow_mcp/tools/feedback_tools.py +238 -0
- package/src/qingflow_mcp/tools/file_tools.py +409 -0
- package/src/qingflow_mcp/tools/import_tools.py +2223 -0
- package/src/qingflow_mcp/tools/navigation_tools.py +210 -0
- package/src/qingflow_mcp/tools/package_tools.py +326 -0
- package/src/qingflow_mcp/tools/portal_tools.py +158 -0
- package/src/qingflow_mcp/tools/qingbi_report_tools.py +374 -0
- package/src/qingflow_mcp/tools/record_tools.py +14291 -0
- package/src/qingflow_mcp/tools/repository_dev_tools.py +552 -0
- package/src/qingflow_mcp/tools/resource_read_tools.py +503 -0
- package/src/qingflow_mcp/tools/role_tools.py +112 -0
- package/src/qingflow_mcp/tools/solution_tools.py +4054 -0
- package/src/qingflow_mcp/tools/task_context_tools.py +2986 -0
- package/src/qingflow_mcp/tools/task_tools.py +889 -0
- package/src/qingflow_mcp/tools/view_tools.py +335 -0
- package/src/qingflow_mcp/tools/workflow_tools.py +376 -0
- package/src/qingflow_mcp/tools/workspace_tools.py +266 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from datetime import date
|
|
5
|
+
|
|
6
|
+
from mcp.server.fastmcp import FastMCP
|
|
7
|
+
|
|
8
|
+
from .backend_client import BackendClient
|
|
9
|
+
from .config import DEFAULT_PROFILE
|
|
10
|
+
from .response_trim import USER_SERVER_METHOD_MAP, trim_error_response, trim_public_response, wrap_trimmed_methods
|
|
11
|
+
from .session_store import SessionStore
|
|
12
|
+
from .tools.app_tools import AppTools
|
|
13
|
+
from .tools.auth_tools import AuthTools
|
|
14
|
+
from .tools.code_block_tools import CodeBlockTools
|
|
15
|
+
from .tools.directory_tools import DirectoryTools
|
|
16
|
+
from .tools.feedback_tools import FeedbackTools
|
|
17
|
+
from .tools.file_tools import FileTools
|
|
18
|
+
from .tools.import_tools import ImportTools
|
|
19
|
+
from .tools.resource_read_tools import ResourceReadTools
|
|
20
|
+
from .tools.task_context_tools import TaskContextTools
|
|
21
|
+
from .tools.workspace_tools import WorkspaceTools
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def build_user_server() -> FastMCP:
|
|
25
|
+
today = date.today()
|
|
26
|
+
current_year = today.year
|
|
27
|
+
server = FastMCP(
|
|
28
|
+
"Qingflow App User MCP",
|
|
29
|
+
instructions=f"""Use this server for Qingflow operational workflows. Current date: `{today.isoformat()}`.
|
|
30
|
+
|
|
31
|
+
## App Discovery
|
|
32
|
+
|
|
33
|
+
If `app_key` is unknown, use `app_list` or `app_search` first.
|
|
34
|
+
If the app is known but the data range is not, use `app_get` first and choose from `accessible_views`.
|
|
35
|
+
If an accessible view has `analysis_supported=false`, do not use it for `record_list` or `record_analyze`. `boardView` and `ganttView` are special UI views, not list/analyze targets.
|
|
36
|
+
|
|
37
|
+
## Shared Helper
|
|
38
|
+
|
|
39
|
+
`feedback_submit` is always available as a cross-cutting helper.
|
|
40
|
+
|
|
41
|
+
- Use it when the current MCP capability is unsupported, awkward, or still cannot satisfy the user's need after reasonable use.
|
|
42
|
+
- It does not require Qingflow login or workspace selection.
|
|
43
|
+
- Call it only after the user explicitly confirms submission.
|
|
44
|
+
|
|
45
|
+
## Schema-First Rule
|
|
46
|
+
|
|
47
|
+
Call `record_insert_schema_get` before `record_insert`.
|
|
48
|
+
Call `record_update_schema_get` before `record_update`.
|
|
49
|
+
Call `record_code_block_schema_get` before `record_code_block_run`.
|
|
50
|
+
Call `app_get` first when the data range is unclear, then use `record_browse_schema_get(view_id=...)` before `record_list`, `record_get`, or `record_analyze`.
|
|
51
|
+
Call `record_import_schema_get` when the import field mapping is unclear before template download or verify.
|
|
52
|
+
|
|
53
|
+
- All `field_id` values must come from the schema response.
|
|
54
|
+
- Never guess field names or ids.
|
|
55
|
+
|
|
56
|
+
## Schema Scope
|
|
57
|
+
|
|
58
|
+
`record_insert_schema_get` returns the current user's insert-ready applicant schema; read `required_fields`, `optional_fields`, `runtime_linked_required_fields`, and `payload_template`.
|
|
59
|
+
Inside `optional_fields`, any field with `may_become_required=true` is still writable, but may become required when linked visibility or option-driven runtime rules activate.
|
|
60
|
+
`record_update_schema_get` returns the current record's overall update-ready writable field set across matched accessible views; read `writable_fields` and `payload_template`.
|
|
61
|
+
`record_browse_schema_get(view_id=...)` returns browse-schema fields for the selected accessible view.
|
|
62
|
+
`record_code_block_schema_get` returns code-block-ready schema for exact code block field selection.
|
|
63
|
+
`record_import_schema_get` returns import-ready column metadata.
|
|
64
|
+
|
|
65
|
+
- Hidden fields are omitted.
|
|
66
|
+
- Missing fields mean the field is not visible in the current permission scope.
|
|
67
|
+
- Read the top-level schema payload directly; do not guess missing writable fields.
|
|
68
|
+
|
|
69
|
+
## Analytics Path
|
|
70
|
+
|
|
71
|
+
`app_get -> record_browse_schema_get(view_id=...) -> record_analyze`
|
|
72
|
+
|
|
73
|
+
Prefer `view_id` entries from `accessible_views` where `analysis_supported=true`.
|
|
74
|
+
|
|
75
|
+
Use this DSL shape:
|
|
76
|
+
|
|
77
|
+
- `dimensions`: `{{field_id, alias, bucket}}`
|
|
78
|
+
- `metrics`: `{{op, field_id, alias}}`
|
|
79
|
+
- `filters`: `{{field_id, op, value}}`
|
|
80
|
+
- `sort`: `{{by, order}}`
|
|
81
|
+
|
|
82
|
+
Important key rules:
|
|
83
|
+
|
|
84
|
+
- Use `op`
|
|
85
|
+
- Do **not** use `type`
|
|
86
|
+
- Do **not** use `agg`
|
|
87
|
+
- Do **not** use `aggregation`
|
|
88
|
+
- Do **not** use `operator`
|
|
89
|
+
|
|
90
|
+
Analysis answers must include concrete numbers. When applicable, include percentages based on the returned totals.
|
|
91
|
+
|
|
92
|
+
## Record CRUD Path
|
|
93
|
+
|
|
94
|
+
`app_get -> record_browse_schema_get(view_id=...) -> record_list / record_get`
|
|
95
|
+
`record_insert_schema_get -> record_insert`
|
|
96
|
+
`record_update_schema_get -> record_update`
|
|
97
|
+
`record_list / record_get -> record_delete`
|
|
98
|
+
`record_code_block_schema_get -> record_code_block_run`
|
|
99
|
+
`portal_list -> portal_get -> chart_get / view_get`
|
|
100
|
+
`portal_get -> view_get -> record_list`
|
|
101
|
+
|
|
102
|
+
- Use `columns` as `[{{field_id}}]`
|
|
103
|
+
- Use `where` items as `{{field_id, op, value}}`
|
|
104
|
+
- Use `order_by` items as `{{field_id, direction}}`
|
|
105
|
+
- Legacy forms such as bare integer `field_id`, `fieldId`, `operator`, `values`, or `order` may still parse, but they are compatibility-only and not the canonical DSL
|
|
106
|
+
|
|
107
|
+
- `record_insert` uses an applicant-node `fields` map keyed by field title.
|
|
108
|
+
- `record_update` uses a field-title keyed `fields` map and internally selects the first accessible view that can execute the current payload.
|
|
109
|
+
- For insert, `runtime_linked_required_fields` means required-but-not-directly-writable fields that are usually supplied by runtime linkage or upstream context.
|
|
110
|
+
- For insert, fields marked `may_become_required=true` stay in `optional_fields`; they are still directly writable, but linked visibility or option-driven rules can make them required at runtime.
|
|
111
|
+
- Read field-level `linkage` whenever present on `record_insert_schema_get` or `record_update_schema_get`; it is the static hint for linked visibility, reference-driven auto fill, and formula/default auto-fill behavior.
|
|
112
|
+
- `linkage.sources` lists upstream field titles that influence the current field; `linkage.affects_fields` lists downstream fields that may change when the current field changes.
|
|
113
|
+
- `linkage.kind=logic_visibility` means linked visibility or option-driven rules are involved; `linkage.kind=reference_fill` means reference/default matching logic is involved; `linkage.kind=formula_fill` means formula/default auto-fill logic is involved.
|
|
114
|
+
- `record_update_schema_get` exposes the overall writable field set for the record, but not every field combination is guaranteed; `record_update` still needs one single matched accessible view that can cover the payload.
|
|
115
|
+
- `record_delete` deletes by `record_id` or `record_ids`.
|
|
116
|
+
- When readback shape matters after insert or update, prefer `record_get(..., output_profile="normalized")` or `record_list(..., output_profile="normalized")`.
|
|
117
|
+
|
|
118
|
+
- Read relation targets from `record_insert_schema_get` / `record_update_schema_get` relation metadata before preparing relation writes.
|
|
119
|
+
- Member and department fields may be written with natural strings directly on `record_insert` / `record_update`; only fall back to `record_member_candidates` or `record_department_candidates` when the user wants explicit candidate browsing or the write returns ambiguity that needs confirmation.
|
|
120
|
+
- When candidate browsing must match a real update/write scope, pass `record_id`, `workflow_node_id`, and any pending `fields` context to the candidate tool; otherwise the candidate result is only a static applicant-node preview.
|
|
121
|
+
- If explicit candidate browsing is needed for default-all member or department fields, prefer those field candidate tools instead of starting with `directory_*`.
|
|
122
|
+
|
|
123
|
+
## Code Block Path
|
|
124
|
+
|
|
125
|
+
Use `record_code_block_run` when the user wants to execute a form code-block field against an existing record.
|
|
126
|
+
|
|
127
|
+
- Always resolve the exact code-block field from `record_code_block_schema_get` first.
|
|
128
|
+
- Treat code-block execution as write-capable, not read-only.
|
|
129
|
+
- If the code block is bound to relation outputs, Qingflow may calculate target answers and write them back automatically.
|
|
130
|
+
- For safe debugging, pass `apply_writeback=false` and inspect the parsed alias results plus `relation.calculated_answers_preview` before allowing any writeback.
|
|
131
|
+
- In workflow context, pass `role=3` and the exact `workflow_node_id`.
|
|
132
|
+
- After execution, inspect `outputs.configured_aliases`, `outputs.alias_results`, `outputs.alias_map`, `relation.target_fields`, and `writeback.verification` before claiming success.
|
|
133
|
+
|
|
134
|
+
## Import Path
|
|
135
|
+
|
|
136
|
+
`app_get -> record_import_schema_get -> record_import_template_get -> record_import_verify -> (optional authorized record_import_repair_local) -> record_import_start -> record_import_status_get`
|
|
137
|
+
|
|
138
|
+
- Check `app_get.data.import_capability` before doing import work.
|
|
139
|
+
- If `import_capability.can_import=false`, stop before template download, file repair, or import start.
|
|
140
|
+
- Import must go through `verify -> start`; do not start directly from a raw file path.
|
|
141
|
+
- `record_import_start` requires an explicit `being_enter_auditing` choice. Do not assume a default.
|
|
142
|
+
- Do not modify user-uploaded files unless the user explicitly authorizes repair.
|
|
143
|
+
- If repair is authorized, keep the original file and repair a copy, then run `record_import_verify` again before `record_import_start`.
|
|
144
|
+
|
|
145
|
+
## Task Workflow Path
|
|
146
|
+
|
|
147
|
+
`task_list -> task_get -> task_action_execute`
|
|
148
|
+
|
|
149
|
+
- `task_list` returns task-card summaries keyed by `task_id`.
|
|
150
|
+
- Prefer `task_get(task_id=...)` for detail reads; MCP resolves the current todo locator internally.
|
|
151
|
+
- `task_action_execute(task_id=..., action=...)` is also supported; MCP resolves the current todo locator internally before calling the real action route.
|
|
152
|
+
- `task_workflow_log_get(task_id=...)` and `task_associated_report_detail_get(task_id=...)` are also supported for the current todo context.
|
|
153
|
+
- Use `task_associated_report_detail_get` for associated view or report details.
|
|
154
|
+
- Use `task_workflow_log_get` for full workflow log history.
|
|
155
|
+
- Task actions operate on `app_key + record_id + workflow_node_id`, not `task_id`.
|
|
156
|
+
- Treat `task_action_execute` as the tool-level action enum surface; the current task's real actions are only the ones listed in `task_get.capabilities.available_actions`.
|
|
157
|
+
- Use `task_action_execute(action="save_only", fields=...)` when the user wants to save editable field changes on the current node without advancing the workflow.
|
|
158
|
+
- `save_only` is exposed only when the backend current-node `editableQueIds` signal returns a non-empty result; MCP no longer infers `save_only` from local schema reconstruction.
|
|
159
|
+
|
|
160
|
+
## Time Handling
|
|
161
|
+
|
|
162
|
+
Normalize relative dates before building DSL.
|
|
163
|
+
|
|
164
|
+
- If the user says `3月` without a year, use the current year: `{current_year}`
|
|
165
|
+
- Convert month-only phrases into explicit legal date ranges
|
|
166
|
+
- Never send impossible dates such as `2026-02-29`
|
|
167
|
+
|
|
168
|
+
## Environment
|
|
169
|
+
|
|
170
|
+
Default to `prod` unless the user explicitly specifies `test`.
|
|
171
|
+
|
|
172
|
+
## Constraints
|
|
173
|
+
|
|
174
|
+
Avoid builder-side app or schema changes here.
|
|
175
|
+
|
|
176
|
+
## Feedback Path
|
|
177
|
+
|
|
178
|
+
If the current MCP capability is unsupported, the workflow is awkward, or the user's need still cannot be satisfied after reasonable use, offer to submit product feedback.
|
|
179
|
+
|
|
180
|
+
- First summarize what is still not working
|
|
181
|
+
- Ask the user whether to submit feedback
|
|
182
|
+
- Call `feedback_submit` only after explicit user confirmation""",
|
|
183
|
+
)
|
|
184
|
+
sessions = SessionStore()
|
|
185
|
+
backend = BackendClient()
|
|
186
|
+
auth = wrap_trimmed_methods(AuthTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
187
|
+
apps = wrap_trimmed_methods(AppTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
188
|
+
workspace = wrap_trimmed_methods(WorkspaceTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
189
|
+
file_tools = wrap_trimmed_methods(FileTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
190
|
+
imports = wrap_trimmed_methods(ImportTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
191
|
+
resources = wrap_trimmed_methods(ResourceReadTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
192
|
+
feedback = FeedbackTools(backend, mcp_side="App User MCP")
|
|
193
|
+
code_block_tools = wrap_trimmed_methods(CodeBlockTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
194
|
+
task_context_tools = wrap_trimmed_methods(TaskContextTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
195
|
+
directory_tools = wrap_trimmed_methods(DirectoryTools(sessions, backend), USER_SERVER_METHOD_MAP)
|
|
196
|
+
|
|
197
|
+
@server.tool()
|
|
198
|
+
def auth_use_credential(
|
|
199
|
+
profile: str = DEFAULT_PROFILE,
|
|
200
|
+
base_url: str | None = None,
|
|
201
|
+
qf_version: str | None = None,
|
|
202
|
+
credential: str = "",
|
|
203
|
+
persist: bool = False,
|
|
204
|
+
) -> dict:
|
|
205
|
+
return auth.auth_use_credential(
|
|
206
|
+
profile=profile,
|
|
207
|
+
base_url=base_url,
|
|
208
|
+
qf_version=qf_version,
|
|
209
|
+
credential=credential,
|
|
210
|
+
persist=persist,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
@server.tool()
|
|
214
|
+
def auth_whoami(profile: str = DEFAULT_PROFILE) -> dict:
|
|
215
|
+
return auth.auth_whoami(profile=profile)
|
|
216
|
+
|
|
217
|
+
@server.tool()
|
|
218
|
+
def auth_logout(profile: str = DEFAULT_PROFILE, forget_persisted: bool = False) -> dict:
|
|
219
|
+
return auth.auth_logout(profile=profile, forget_persisted=forget_persisted)
|
|
220
|
+
|
|
221
|
+
@server.tool()
|
|
222
|
+
def workspace_list(
|
|
223
|
+
profile: str = DEFAULT_PROFILE,
|
|
224
|
+
page_num: int = 1,
|
|
225
|
+
page_size: int = 20,
|
|
226
|
+
include_external: bool = False,
|
|
227
|
+
) -> dict:
|
|
228
|
+
return workspace.workspace_list(
|
|
229
|
+
profile=profile,
|
|
230
|
+
page_num=page_num,
|
|
231
|
+
page_size=page_size,
|
|
232
|
+
include_external=include_external,
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
@server.tool()
|
|
236
|
+
def workspace_get(
|
|
237
|
+
profile: str = DEFAULT_PROFILE,
|
|
238
|
+
ws_id: int | None = None,
|
|
239
|
+
) -> dict:
|
|
240
|
+
return workspace.workspace_get(
|
|
241
|
+
profile=profile,
|
|
242
|
+
ws_id=ws_id,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
@server.tool()
|
|
246
|
+
def workspace_select(
|
|
247
|
+
profile: str = DEFAULT_PROFILE,
|
|
248
|
+
ws_id: int = 0,
|
|
249
|
+
) -> dict:
|
|
250
|
+
return workspace.workspace_select(
|
|
251
|
+
profile=profile,
|
|
252
|
+
ws_id=ws_id,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
@server.tool()
|
|
256
|
+
def app_list(profile: str = DEFAULT_PROFILE) -> dict:
|
|
257
|
+
return apps.app_list(profile=profile)
|
|
258
|
+
|
|
259
|
+
@server.tool()
|
|
260
|
+
def app_search(profile: str = DEFAULT_PROFILE, keyword: str = "", page_num: int = 1, page_size: int = 50) -> dict:
|
|
261
|
+
return apps.app_search(profile=profile, keyword=keyword, page_num=page_num, page_size=page_size)
|
|
262
|
+
|
|
263
|
+
@server.tool()
|
|
264
|
+
def app_get(profile: str = DEFAULT_PROFILE, app_key: str = "") -> dict:
|
|
265
|
+
return apps.app_get(profile=profile, app_key=app_key)
|
|
266
|
+
|
|
267
|
+
@server.tool()
|
|
268
|
+
def portal_list(profile: str = DEFAULT_PROFILE) -> dict:
|
|
269
|
+
return resources.portal_list(profile=profile)
|
|
270
|
+
|
|
271
|
+
@server.tool()
|
|
272
|
+
def portal_get(profile: str = DEFAULT_PROFILE, dash_key: str = "") -> dict:
|
|
273
|
+
return resources.portal_get(profile=profile, dash_key=dash_key)
|
|
274
|
+
|
|
275
|
+
@server.tool()
|
|
276
|
+
def view_get(profile: str = DEFAULT_PROFILE, view_id: str = "") -> dict:
|
|
277
|
+
return resources.view_get(profile=profile, view_id=view_id)
|
|
278
|
+
|
|
279
|
+
@server.tool()
|
|
280
|
+
def chart_get(profile: str = DEFAULT_PROFILE, chart_id: str = "") -> dict:
|
|
281
|
+
return resources.chart_get(profile=profile, chart_id=chart_id)
|
|
282
|
+
|
|
283
|
+
@server.tool()
|
|
284
|
+
def file_get_upload_info(
|
|
285
|
+
profile: str = DEFAULT_PROFILE,
|
|
286
|
+
upload_kind: str = "attachment",
|
|
287
|
+
file_name: str = "",
|
|
288
|
+
file_size: int = 0,
|
|
289
|
+
upload_mark: str | None = None,
|
|
290
|
+
content_type: str | None = None,
|
|
291
|
+
bucket_type: str | None = None,
|
|
292
|
+
path_id: int | None = None,
|
|
293
|
+
file_related_url: str | None = None,
|
|
294
|
+
) -> dict:
|
|
295
|
+
return file_tools.file_get_upload_info(
|
|
296
|
+
profile=profile,
|
|
297
|
+
upload_kind=upload_kind,
|
|
298
|
+
file_name=file_name,
|
|
299
|
+
file_size=file_size,
|
|
300
|
+
upload_mark=upload_mark,
|
|
301
|
+
content_type=content_type,
|
|
302
|
+
bucket_type=bucket_type,
|
|
303
|
+
path_id=path_id,
|
|
304
|
+
file_related_url=file_related_url,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
@server.tool()
|
|
308
|
+
def file_upload_local(
|
|
309
|
+
profile: str = DEFAULT_PROFILE,
|
|
310
|
+
upload_kind: str = "attachment",
|
|
311
|
+
file_path: str = "",
|
|
312
|
+
upload_mark: str | None = None,
|
|
313
|
+
content_type: str | None = None,
|
|
314
|
+
bucket_type: str | None = None,
|
|
315
|
+
path_id: int | None = None,
|
|
316
|
+
file_related_url: str | None = None,
|
|
317
|
+
) -> dict:
|
|
318
|
+
return file_tools.file_upload_local(
|
|
319
|
+
profile=profile,
|
|
320
|
+
upload_kind=upload_kind,
|
|
321
|
+
file_path=file_path,
|
|
322
|
+
upload_mark=upload_mark,
|
|
323
|
+
content_type=content_type,
|
|
324
|
+
bucket_type=bucket_type,
|
|
325
|
+
path_id=path_id,
|
|
326
|
+
file_related_url=file_related_url,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
imports.register(server)
|
|
330
|
+
|
|
331
|
+
@server.tool()
|
|
332
|
+
def feedback_submit(
|
|
333
|
+
category: str = "",
|
|
334
|
+
title: str = "",
|
|
335
|
+
description: str = "",
|
|
336
|
+
expected_behavior: str | None = None,
|
|
337
|
+
actual_behavior: str | None = None,
|
|
338
|
+
impact_scope: str | None = None,
|
|
339
|
+
tool_name: str | None = None,
|
|
340
|
+
app_key: str | None = None,
|
|
341
|
+
record_id: str | int | None = None,
|
|
342
|
+
workflow_node_id: str | int | None = None,
|
|
343
|
+
note: str | None = None,
|
|
344
|
+
) -> dict:
|
|
345
|
+
try:
|
|
346
|
+
return trim_public_response(
|
|
347
|
+
"user:feedback_submit",
|
|
348
|
+
feedback.feedback_submit(
|
|
349
|
+
category=category,
|
|
350
|
+
title=title,
|
|
351
|
+
description=description,
|
|
352
|
+
expected_behavior=expected_behavior,
|
|
353
|
+
actual_behavior=actual_behavior,
|
|
354
|
+
impact_scope=impact_scope,
|
|
355
|
+
tool_name=tool_name,
|
|
356
|
+
app_key=app_key,
|
|
357
|
+
record_id=record_id,
|
|
358
|
+
workflow_node_id=workflow_node_id,
|
|
359
|
+
note=note,
|
|
360
|
+
),
|
|
361
|
+
)
|
|
362
|
+
except RuntimeError as exc:
|
|
363
|
+
try:
|
|
364
|
+
payload = json.loads(str(exc))
|
|
365
|
+
except json.JSONDecodeError:
|
|
366
|
+
raise
|
|
367
|
+
if isinstance(payload, dict):
|
|
368
|
+
raise RuntimeError(json.dumps(trim_error_response(payload), ensure_ascii=False)) from None
|
|
369
|
+
raise
|
|
370
|
+
|
|
371
|
+
code_block_tools.register(server)
|
|
372
|
+
task_context_tools.register(server)
|
|
373
|
+
directory_tools.register(server)
|
|
374
|
+
|
|
375
|
+
return server
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
mcp = build_user_server()
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def main() -> None:
|
|
382
|
+
mcp.run()
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
if __name__ == "__main__":
|
|
386
|
+
main()
|