@taiga-ui/mcp 0.1.0-alpha.1
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/LICENSE +190 -0
- package/README.md +137 -0
- package/dist/index.js +7 -0
- package/dist/schemas/doc-types.js +1 -0
- package/dist/server/fetch.js +31 -0
- package/dist/server/server.js +26 -0
- package/dist/tools/get-component-example.js +42 -0
- package/dist/tools/get-list-components.js +38 -0
- package/dist/tools/index.js +6 -0
- package/dist/utils/find-section.js +64 -0
- package/dist/utils/list-components.js +20 -0
- package/dist/utils/logger.js +7 -0
- package/dist/utils/parse-content.js +38 -0
- package/dist/utils/query-results.js +39 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2024 Acpekt
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Taiga UI MCP Server
|
|
2
|
+
|
|
3
|
+
> **🚀 The fastest way to integrate Taiga UI components into your AI workflow**
|
|
4
|
+
|
|
5
|
+
A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to [Taiga UI](https://taiga-ui.dev) components. Seamlessly retrieve Taiga UI components implementations for your AI-powered development workflow.
|
|
6
|
+
|
|
7
|
+
## Integrate with Your Editor
|
|
8
|
+
|
|
9
|
+
### VS Code
|
|
10
|
+
|
|
11
|
+
To configure MCP in VS Code with GitHub Copilot, add the taiga-ui server to your project's `.vscode/mcp.json` configuration file:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"taiga-ui": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": [
|
|
19
|
+
"@taiga-ui/mcp@latest",
|
|
20
|
+
"--source-url=https://taiga-ui.dev/llms-full.txt" // or file from "/next" version, if you want
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Provided Tools
|
|
28
|
+
|
|
29
|
+
1. `get_list_components { query?: string }`
|
|
30
|
+
|
|
31
|
+
- Lists component / section identifiers (with fuzzy substring filtering) along with basic metadata (category, package, type).
|
|
32
|
+
- Input: optional `query` string to filter IDs (case-insensitive substring).
|
|
33
|
+
- Output: `{ items: [...], total, query }` strictly structured JSON.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
{
|
|
37
|
+
"items": [
|
|
38
|
+
{ "id": "components/Alert", "name": "Alert", "category": "components", "package": "CORE", "type": "component" }
|
|
39
|
+
],
|
|
40
|
+
"total": 1,
|
|
41
|
+
"query": null
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. `get_component_example { "names": ["...", "..."] }`
|
|
46
|
+
|
|
47
|
+
- Returns the full markdown content of each resolved section (entire component documentation). Applies fuzzy name resolution (variants: exact, segment, suffix, substring with Tui\* variants).
|
|
48
|
+
- Input: `{ names: string[] }` (each >= 2 chars).
|
|
49
|
+
- Output: per name object with `id` (present only if resolved), `package`, `type`, `suggestions` (only when unresolved), and `content` (array of code strings when example blocks exist; omitted otherwise). Top-level also includes `matched` (count of resolved names).
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
{
|
|
53
|
+
"results": [
|
|
54
|
+
{
|
|
55
|
+
"query": "Alert",
|
|
56
|
+
"id": "components/Alert",
|
|
57
|
+
"package": "CORE",
|
|
58
|
+
"type": "component",
|
|
59
|
+
"content": ["# components/Alert\n- **Package**: ... (full section markdown here)"]
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"matched": 1
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Authors
|
|
67
|
+
|
|
68
|
+
<table>
|
|
69
|
+
<tr>
|
|
70
|
+
<td align="center">
|
|
71
|
+
<a href="https://github.com/vladimirpotekhin"
|
|
72
|
+
><img
|
|
73
|
+
src="https://github.com/vladimirpotekhin.png?size=200"
|
|
74
|
+
width="100"
|
|
75
|
+
style="margin-bottom: -4px; border-radius: 8px;"
|
|
76
|
+
alt="Vladimir Potekhin"
|
|
77
|
+
/><br /><b>Vladimir Potekhin</b></a
|
|
78
|
+
>
|
|
79
|
+
<div style="margin-top: 4px">
|
|
80
|
+
<a
|
|
81
|
+
href="https://twitter.com/v_potekhin"
|
|
82
|
+
title="Twitter"
|
|
83
|
+
><img
|
|
84
|
+
width="16"
|
|
85
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg"
|
|
86
|
+
/></a>
|
|
87
|
+
<a
|
|
88
|
+
href="https://github.com/vladimirpotekhin"
|
|
89
|
+
title="GitHub"
|
|
90
|
+
><img
|
|
91
|
+
width="16"
|
|
92
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg"
|
|
93
|
+
/></a>
|
|
94
|
+
<a
|
|
95
|
+
href="https://t.me/v_potekhin"
|
|
96
|
+
title="Telegram"
|
|
97
|
+
><img
|
|
98
|
+
width="16"
|
|
99
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg"
|
|
100
|
+
/></a>
|
|
101
|
+
</div>
|
|
102
|
+
</td>
|
|
103
|
+
<td align="center">
|
|
104
|
+
<a href="https://github.com/mdlufy"
|
|
105
|
+
><img
|
|
106
|
+
src="https://github.com/mdlufy.png?size=200"
|
|
107
|
+
width="100"
|
|
108
|
+
style="margin-bottom: -4px; border-radius: 8px;"
|
|
109
|
+
alt="German Panov"
|
|
110
|
+
/><br /><b>German Panov</b></a
|
|
111
|
+
>
|
|
112
|
+
<div style="margin-top: 4px">
|
|
113
|
+
<a
|
|
114
|
+
href="https://twitter.com/mdlufy_"
|
|
115
|
+
title="Twitter"
|
|
116
|
+
><img
|
|
117
|
+
width="16"
|
|
118
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg"
|
|
119
|
+
/></a>
|
|
120
|
+
<a
|
|
121
|
+
href="https://github.com/mdlufy"
|
|
122
|
+
title="GitHub"
|
|
123
|
+
><img
|
|
124
|
+
width="16"
|
|
125
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg"
|
|
126
|
+
/></a>
|
|
127
|
+
<a
|
|
128
|
+
href="https://t.me/mdlufy"
|
|
129
|
+
title="Telegram"
|
|
130
|
+
><img
|
|
131
|
+
width="16"
|
|
132
|
+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg"
|
|
133
|
+
/></a>
|
|
134
|
+
</div>
|
|
135
|
+
</td>
|
|
136
|
+
</tr>
|
|
137
|
+
</table>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { state } from './server.js';
|
|
2
|
+
import { parseContent } from '../utils/parse-content.js';
|
|
3
|
+
// 6-hour refresh window
|
|
4
|
+
const REFRESH_INTERVAL_MS = 6 * 60 * 60 * 1000;
|
|
5
|
+
export async function fetchSource() {
|
|
6
|
+
const argProvidedUrl = process.argv
|
|
7
|
+
.find((arg) => arg.startsWith('--source-url='))
|
|
8
|
+
?.split('=')[1];
|
|
9
|
+
const sourceUrl = argProvidedUrl || process.env.SOURCE_URL;
|
|
10
|
+
if (!sourceUrl) {
|
|
11
|
+
throw new Error('Source URL not provided. Set SOURCE_URL or pass --source-url=...');
|
|
12
|
+
}
|
|
13
|
+
const response = await fetch(sourceUrl).catch((error) => {
|
|
14
|
+
throw new Error(`Network error fetching documentation source: ${error?.message || error}`);
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok)
|
|
17
|
+
throw new Error(`Failed to fetch documentation (HTTP ${response.status} ${response.statusText}) from ${sourceUrl}`);
|
|
18
|
+
const content = await response.text();
|
|
19
|
+
if (!content.trim())
|
|
20
|
+
throw new Error(`Fetched documentation from ${sourceUrl} is empty.`);
|
|
21
|
+
return { url: sourceUrl, content };
|
|
22
|
+
}
|
|
23
|
+
export async function ensureSourceLoaded() {
|
|
24
|
+
const isContentStale = !state.lastLoadedAt ||
|
|
25
|
+
Date.now() - state.lastLoadedAt > REFRESH_INTERVAL_MS;
|
|
26
|
+
if (!(state.sections.length > 0) || isContentStale) {
|
|
27
|
+
const { url, content } = await fetchSource();
|
|
28
|
+
parseContent(content, url);
|
|
29
|
+
state.lastLoadedAt = Date.now();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { ensureSourceLoaded } from './fetch.js';
|
|
5
|
+
import { registerAllTools } from '../tools/index.js';
|
|
6
|
+
export const state = {
|
|
7
|
+
sections: [],
|
|
8
|
+
sourceUrl: undefined,
|
|
9
|
+
lastLoadedAt: undefined,
|
|
10
|
+
};
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: 'taiga-ui-mcp',
|
|
13
|
+
version: '0.1.0-alpha.1',
|
|
14
|
+
});
|
|
15
|
+
registerAllTools(server);
|
|
16
|
+
export async function start() {
|
|
17
|
+
try {
|
|
18
|
+
await ensureSourceLoaded();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Initial source load failed:', error);
|
|
22
|
+
}
|
|
23
|
+
const transport = new StdioServerTransport();
|
|
24
|
+
await server.connect(transport);
|
|
25
|
+
console.error(`Angular Taiga UI MCP Server running. Fetched source components: ${state.sections.length}`);
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ensureSourceLoaded } from '../server/fetch.js';
|
|
3
|
+
import { buildQueryResults } from '../utils/query-results.js';
|
|
4
|
+
export function registerGetComponentExampleTool(server) {
|
|
5
|
+
server.registerTool('get_component_example', {
|
|
6
|
+
title: 'Get Component Example',
|
|
7
|
+
description: 'Return section-related content snippets (formerly examples) for specified documentation section name(s). The presence of id indicates a successful match.',
|
|
8
|
+
inputSchema: { names: z.array(z.string().min(2)).min(1) },
|
|
9
|
+
outputSchema: {
|
|
10
|
+
results: z.array(z.object({
|
|
11
|
+
query: z.string(),
|
|
12
|
+
id: z.string().optional(),
|
|
13
|
+
package: z.string().nullable().optional(),
|
|
14
|
+
type: z.string().nullable().optional(),
|
|
15
|
+
suggestions: z.array(z.string()).optional(),
|
|
16
|
+
content: z.array(z.string()).optional(),
|
|
17
|
+
})),
|
|
18
|
+
matched: z.number(),
|
|
19
|
+
},
|
|
20
|
+
}, async ({ names }) => {
|
|
21
|
+
if (!names || !names.length) {
|
|
22
|
+
const output = {
|
|
23
|
+
error: 'Provide at least one name in names array.',
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{ type: 'text', text: JSON.stringify(output, null, 2) },
|
|
28
|
+
],
|
|
29
|
+
structuredContent: output,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
await ensureSourceLoaded();
|
|
33
|
+
const { results, matches } = buildQueryResults(names);
|
|
34
|
+
const output = { results, matched: matches };
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{ type: 'text', text: JSON.stringify(output, null, 2) },
|
|
38
|
+
],
|
|
39
|
+
structuredContent: output,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ensureSourceLoaded } from '../server/fetch.js';
|
|
3
|
+
import { constructComponentsList } from '../utils/list-components.js';
|
|
4
|
+
export function registerGetListComponentsTool(server) {
|
|
5
|
+
server.registerTool('get_list_components', {
|
|
6
|
+
title: 'List Components',
|
|
7
|
+
description: 'List all Taiga UI documentation section IDs (structured JSON only).',
|
|
8
|
+
inputSchema: { query: z.string().optional() },
|
|
9
|
+
outputSchema: {
|
|
10
|
+
items: z.array(z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
category: z.string(),
|
|
14
|
+
package: z.string().nullable(),
|
|
15
|
+
type: z.string().nullable(),
|
|
16
|
+
})),
|
|
17
|
+
total: z.number(),
|
|
18
|
+
query: z.string().nullable(),
|
|
19
|
+
},
|
|
20
|
+
}, async ({ query }) => {
|
|
21
|
+
await ensureSourceLoaded();
|
|
22
|
+
const { items, normalizedQuery } = constructComponentsList(query);
|
|
23
|
+
const output = {
|
|
24
|
+
items,
|
|
25
|
+
total: items.length,
|
|
26
|
+
query: normalizedQuery,
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: JSON.stringify(output, null, 2),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
structuredContent: output,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { registerGetListComponentsTool } from './get-list-components.js';
|
|
2
|
+
import { registerGetComponentExampleTool } from './get-component-example.js';
|
|
3
|
+
export function registerAllTools(server) {
|
|
4
|
+
registerGetListComponentsTool(server);
|
|
5
|
+
registerGetComponentExampleTool(server);
|
|
6
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { state } from '../server/server.js';
|
|
2
|
+
export function findSection(name) {
|
|
3
|
+
const pascalCase = name
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.split(/[-_\s]+/)
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
8
|
+
.join('');
|
|
9
|
+
const camelCase = pascalCase
|
|
10
|
+
? pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1)
|
|
11
|
+
: '';
|
|
12
|
+
const tuiVariant = pascalCase.startsWith('Tui')
|
|
13
|
+
? pascalCase
|
|
14
|
+
: 'Tui' + pascalCase;
|
|
15
|
+
const variants = [
|
|
16
|
+
name.toLowerCase(),
|
|
17
|
+
pascalCase,
|
|
18
|
+
camelCase,
|
|
19
|
+
tuiVariant,
|
|
20
|
+
tuiVariant.toLowerCase(),
|
|
21
|
+
].filter(Boolean);
|
|
22
|
+
// Exact match
|
|
23
|
+
for (const variant of variants) {
|
|
24
|
+
const exactMatch = state.sections.find((section) => section.id.toLowerCase() === variant.toLowerCase());
|
|
25
|
+
if (exactMatch)
|
|
26
|
+
return exactMatch;
|
|
27
|
+
}
|
|
28
|
+
// Last path segment match
|
|
29
|
+
for (const variant of variants) {
|
|
30
|
+
const segmentMatch = state.sections.find((section) => section.id.split('/').pop()?.toLowerCase() ===
|
|
31
|
+
variant.toLowerCase());
|
|
32
|
+
if (segmentMatch)
|
|
33
|
+
return segmentMatch;
|
|
34
|
+
}
|
|
35
|
+
// Ends-with match
|
|
36
|
+
for (const variant of variants) {
|
|
37
|
+
const endsWithMatch = state.sections.find((section) => section.id.toLowerCase().endsWith('/' + variant.toLowerCase()));
|
|
38
|
+
if (endsWithMatch)
|
|
39
|
+
return endsWithMatch;
|
|
40
|
+
}
|
|
41
|
+
// Substring fallback
|
|
42
|
+
const substringMatch = state.sections.find((section) => section.id.toLowerCase().includes(name.toLowerCase()));
|
|
43
|
+
if (substringMatch)
|
|
44
|
+
return substringMatch;
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
export function suggestSections(query) {
|
|
48
|
+
const normalizedQuery = query.toLowerCase();
|
|
49
|
+
return state.sections
|
|
50
|
+
.map((section) => {
|
|
51
|
+
const sectionIdLower = section.id.toLowerCase();
|
|
52
|
+
const matchIndex = sectionIdLower.indexOf(normalizedQuery);
|
|
53
|
+
return matchIndex === -1
|
|
54
|
+
? null
|
|
55
|
+
: {
|
|
56
|
+
id: section.id,
|
|
57
|
+
score: matchIndex * 10 +
|
|
58
|
+
Math.abs(sectionIdLower.length - normalizedQuery.length),
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
.filter((candidate) => !!candidate)
|
|
62
|
+
.sort((a, b) => a.score - b.score)
|
|
63
|
+
.map((result) => result.id);
|
|
64
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { state } from '../server/server.js';
|
|
2
|
+
export function constructComponentsList(query) {
|
|
3
|
+
const normalizedQuery = query ? query.toLowerCase() : null;
|
|
4
|
+
const items = state.sections
|
|
5
|
+
.filter((section) => !normalizedQuery ||
|
|
6
|
+
section.id.toLowerCase().includes(normalizedQuery))
|
|
7
|
+
.map((section) => {
|
|
8
|
+
const idParts = section.id.split('/');
|
|
9
|
+
const name = idParts[idParts.length - 1] || section.id;
|
|
10
|
+
const category = idParts[0] || '';
|
|
11
|
+
return {
|
|
12
|
+
id: section.id,
|
|
13
|
+
name,
|
|
14
|
+
category,
|
|
15
|
+
package: section.package ?? null,
|
|
16
|
+
type: section.kind ?? null,
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
return { items, normalizedQuery };
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { state } from '../server/server.js';
|
|
2
|
+
function extractMeta(text) {
|
|
3
|
+
let pkg;
|
|
4
|
+
let kind;
|
|
5
|
+
const pkgMatch = /\*\*Package\*\*:\s*`([^`]+)`/i.exec(text);
|
|
6
|
+
if (pkgMatch)
|
|
7
|
+
pkg = pkgMatch[1];
|
|
8
|
+
const typeMatch = /\*\*Type\*\*:\s*([^\n]+)/i.exec(text);
|
|
9
|
+
if (typeMatch)
|
|
10
|
+
kind = typeMatch[1].trim();
|
|
11
|
+
return { package: pkg, kind };
|
|
12
|
+
}
|
|
13
|
+
export function parseContent(rawContent, sourceUrl) {
|
|
14
|
+
state.sourceUrl = sourceUrl;
|
|
15
|
+
const lines = rawContent.split(/\r?\n/);
|
|
16
|
+
const headerIndices = [];
|
|
17
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
18
|
+
const headerMatch = /^#\s+(.+)$/.exec(lines[lineIndex]);
|
|
19
|
+
if (headerMatch)
|
|
20
|
+
headerIndices.push({
|
|
21
|
+
line: lineIndex,
|
|
22
|
+
title: headerMatch[1].trim(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
state.sections = headerIndices.map((header, headerIndex) => {
|
|
26
|
+
const start = header.line;
|
|
27
|
+
const end = headerIndices[headerIndex + 1]?.line ?? lines.length;
|
|
28
|
+
const content = lines.slice(start, end).join('\n');
|
|
29
|
+
const meta = extractMeta(content);
|
|
30
|
+
return {
|
|
31
|
+
id: header.title,
|
|
32
|
+
title: header.title,
|
|
33
|
+
content,
|
|
34
|
+
package: meta.package,
|
|
35
|
+
kind: meta.kind,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { findSection, suggestSections } from './find-section.js';
|
|
2
|
+
export function extractContentSnippets(section) {
|
|
3
|
+
const text = section.content || '';
|
|
4
|
+
const trimmed = text.trim();
|
|
5
|
+
if (!trimmed)
|
|
6
|
+
return [];
|
|
7
|
+
const cleaned = trimmed
|
|
8
|
+
.split(/\r?\n/)
|
|
9
|
+
.map((line) => line.replace(/^#{1,6}\s*/, ''))
|
|
10
|
+
.join('\n')
|
|
11
|
+
.trim();
|
|
12
|
+
return cleaned ? [cleaned] : [];
|
|
13
|
+
}
|
|
14
|
+
export function buildQueryResults(names) {
|
|
15
|
+
const results = [];
|
|
16
|
+
for (const queryName of names) {
|
|
17
|
+
const section = findSection(queryName);
|
|
18
|
+
if (!section) {
|
|
19
|
+
const notFound = {
|
|
20
|
+
query: queryName,
|
|
21
|
+
suggestions: suggestSections(queryName),
|
|
22
|
+
};
|
|
23
|
+
results.push(notFound);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const snippets = extractContentSnippets(section);
|
|
27
|
+
const foundResult = {
|
|
28
|
+
query: queryName,
|
|
29
|
+
id: section.id,
|
|
30
|
+
package: section.package || null,
|
|
31
|
+
type: section.kind || null,
|
|
32
|
+
};
|
|
33
|
+
if (snippets.length)
|
|
34
|
+
foundResult.content = snippets;
|
|
35
|
+
results.push(foundResult);
|
|
36
|
+
}
|
|
37
|
+
const matches = results.filter((result) => !!result.id).length;
|
|
38
|
+
return { results, matches };
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taiga-ui/mcp",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Model Context Protocol server providing Taiga UI documentation search and scaffolding tools.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"taiga-ui-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**/*",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"taiga-ui",
|
|
19
|
+
"taiga-ui-mcp",
|
|
20
|
+
"ui-components",
|
|
21
|
+
"typescript",
|
|
22
|
+
"ai-tools",
|
|
23
|
+
"claude",
|
|
24
|
+
"copilot"
|
|
25
|
+
],
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"homepage": "https://github.com/taiga-family/taiga-ui-mcp#README",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/taiga-family/taiga-ui-mcp/issues"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/taiga-family/taiga-ui-mcp.git"
|
|
34
|
+
},
|
|
35
|
+
"authors": [
|
|
36
|
+
"Vladimir Potekhin <vladimir.potekh@gmail.com>",
|
|
37
|
+
"German Panov <zidakbew@gmail.com>"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"start": "node dist/index.js",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"build": "npm run clean && tsc && chmod +x dist/index.js",
|
|
43
|
+
"prepublishOnly": "npm run build",
|
|
44
|
+
"release": "npm run build && npm publish --access public --tag alpha"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.20.0",
|
|
51
|
+
"zod": "^3.25.76"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@taiga-ui/release-it-config": "0.344.0",
|
|
55
|
+
"@taiga-ui/auto-changelog-config": "0.344.0",
|
|
56
|
+
"@types/node": "^24.7.2",
|
|
57
|
+
"typescript": "^5.9.3"
|
|
58
|
+
}
|
|
59
|
+
}
|