Commit 72adfdc
* fix: surface source description in MCP tool description
The `description` field on TOML [[sources]] was parsed into SourceConfig
and exposed via the REST /api/sources endpoint, but never surfaced
through MCP tool metadata. AI clients using DBHub via MCP only saw the
hardcoded template "Execute SQL queries on the '<id>' <dbType> database"
regardless of how the user described the source, making it impossible
for models to route requests between multiple sources based on the
user's descriptions.
Prepend sourceConfig.description (when set) to both execute_sql and
search_objects generated tool descriptions so AI clients see the
source's purpose first while retaining all existing technical context
(readonly note, max_rows note, dbType, source id).
Custom tool descriptions (CustomToolConfig.description) are untouched
because custom tools already carry their own required description.
Fixes #267
* refactor: extract buildSourceDescriptionPrefix helper and normalize input
Addresses Copilot review feedback on PR #309:
- Extract prefix-building logic into a pure helper `buildSourceDescriptionPrefix`
used by both `getExecuteSqlMetadata` and `getSearchObjectsMetadata` instead
of inlining the same expression twice.
- Trim surrounding whitespace from the user-provided description so leading
or trailing whitespace does not leak into the MCP tool description.
- Skip appending '.' when the description already ends with a sentence-ending
character (one of '.', '!', '?') to avoid double punctuation such as
"Prod DB.. Execute SQL...".
Adds 10 pure unit tests in src/utils/__tests__/tool-metadata.test.ts
covering undefined/empty/whitespace-only inputs, each sentence-ending
punctuation case, whitespace trimming, preservation of internal formatting,
and documenting that mid-sentence punctuation (':', ';', ')') is still
terminated with '. '.
* refactor: treat trailing ':' as terminator to avoid ':.' artifact
Addresses second-pass Copilot review on PR #309: descriptions ending
with a colon (e.g. "Details below:") produced the awkward artifact
"Details below:. Execute SQL..." under the previous regex.
A trailing colon naturally introduces what follows (the generic tool
template), so appending "." after it is both ugly and semantically
redundant. Extend the terminator regex to /[.!?:]$/ and update the
corresponding test case. ';' and ')' remain non-terminators because
they signal mid-sentence continuation rather than introduction.
---------
Co-authored-by: IslaLiu <C19087@csccss.com.tw>
1 parent f35144b commit 72adfdc
3 files changed
Lines changed: 172 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
43 | 70 | | |
44 | 71 | | |
| |||
106 | 133 | | |
107 | 134 | | |
108 | 135 | | |
109 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
110 | 140 | | |
111 | 141 | | |
112 | 142 | | |
113 | | - | |
114 | | - | |
| 143 | + | |
| 144 | + | |
115 | 145 | | |
116 | 146 | | |
117 | 147 | | |
| |||
149 | 179 | | |
150 | 180 | | |
151 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
152 | 185 | | |
153 | | - | |
154 | | - | |
| 186 | + | |
| 187 | + | |
155 | 188 | | |
156 | 189 | | |
157 | 190 | | |
| |||
0 commit comments