@triedotdev/mcp 1.0.63 → 1.0.64
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/index.js +156 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3291,8 +3291,8 @@ function generateChangelogLookup(library, fromVersion, toVersion) {
|
|
|
3291
3291
|
`;
|
|
3292
3292
|
return prompt;
|
|
3293
3293
|
}
|
|
3294
|
-
function lookupKnowledge(
|
|
3295
|
-
const { type, query, context = {} } =
|
|
3294
|
+
function lookupKnowledge(request2) {
|
|
3295
|
+
const { type, query, context = {} } = request2;
|
|
3296
3296
|
switch (type) {
|
|
3297
3297
|
case "cve":
|
|
3298
3298
|
return generateCVELookup(query, context.version);
|
|
@@ -6629,6 +6629,7 @@ Use \`trie_init\` to create one, or create it manually with team ownership info.
|
|
|
6629
6629
|
// src/tools/visual-qa-browser.ts
|
|
6630
6630
|
import { chromium } from "playwright";
|
|
6631
6631
|
import { createServer } from "net";
|
|
6632
|
+
import { request } from "http";
|
|
6632
6633
|
var DEFAULT_VIEWPORTS = [
|
|
6633
6634
|
{ name: "mobile", width: 375, height: 812 },
|
|
6634
6635
|
// iPhone X
|
|
@@ -6639,29 +6640,62 @@ var DEFAULT_VIEWPORTS = [
|
|
|
6639
6640
|
];
|
|
6640
6641
|
async function findOpenPort() {
|
|
6641
6642
|
const commonPorts = [3e3, 3001, 5173, 5174, 4200, 8080, 8e3, 8888, 5e3, 4e3];
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
return port;
|
|
6646
|
-
}
|
|
6647
|
-
|
|
6648
|
-
return null;
|
|
6643
|
+
const portChecks = await Promise.all(
|
|
6644
|
+
commonPorts.map(async (port) => {
|
|
6645
|
+
const isOpen = await checkPort(port);
|
|
6646
|
+
return isOpen ? port : null;
|
|
6647
|
+
})
|
|
6648
|
+
);
|
|
6649
|
+
return portChecks.find((port) => port !== null) || null;
|
|
6649
6650
|
}
|
|
6650
6651
|
async function checkPort(port) {
|
|
6651
6652
|
return new Promise((resolve6) => {
|
|
6652
|
-
const
|
|
6653
|
-
|
|
6653
|
+
const testServer = createServer();
|
|
6654
|
+
let portInUse = false;
|
|
6655
|
+
testServer.once("error", (err) => {
|
|
6654
6656
|
if (err.code === "EADDRINUSE") {
|
|
6655
|
-
|
|
6657
|
+
portInUse = true;
|
|
6658
|
+
testHttpPort(port).then(resolve6).catch(() => resolve6(false));
|
|
6656
6659
|
} else {
|
|
6657
6660
|
resolve6(false);
|
|
6658
6661
|
}
|
|
6659
6662
|
});
|
|
6660
|
-
|
|
6661
|
-
|
|
6663
|
+
testServer.once("listening", () => {
|
|
6664
|
+
testServer.close();
|
|
6665
|
+
resolve6(false);
|
|
6666
|
+
});
|
|
6667
|
+
setTimeout(() => {
|
|
6668
|
+
if (!portInUse) {
|
|
6669
|
+
testServer.close();
|
|
6670
|
+
resolve6(false);
|
|
6671
|
+
}
|
|
6672
|
+
}, 1e3);
|
|
6673
|
+
testServer.listen(port, "127.0.0.1");
|
|
6674
|
+
});
|
|
6675
|
+
}
|
|
6676
|
+
async function testHttpPort(port) {
|
|
6677
|
+
return new Promise((resolve6) => {
|
|
6678
|
+
const req = request({
|
|
6679
|
+
hostname: "localhost",
|
|
6680
|
+
port,
|
|
6681
|
+
path: "/",
|
|
6682
|
+
method: "GET",
|
|
6683
|
+
timeout: 2e3
|
|
6684
|
+
}, (res) => {
|
|
6685
|
+
resolve6(res.statusCode !== void 0);
|
|
6686
|
+
res.on("data", () => {
|
|
6687
|
+
});
|
|
6688
|
+
res.on("end", () => {
|
|
6689
|
+
});
|
|
6690
|
+
});
|
|
6691
|
+
req.on("error", () => {
|
|
6692
|
+
resolve6(false);
|
|
6693
|
+
});
|
|
6694
|
+
req.on("timeout", () => {
|
|
6695
|
+
req.destroy();
|
|
6662
6696
|
resolve6(false);
|
|
6663
6697
|
});
|
|
6664
|
-
|
|
6698
|
+
req.end();
|
|
6665
6699
|
});
|
|
6666
6700
|
}
|
|
6667
6701
|
async function captureScreenshots(url, viewports, options) {
|
|
@@ -6711,17 +6745,42 @@ async function captureScreenshots(url, viewports, options) {
|
|
|
6711
6745
|
async function runVisualQA(options = {}) {
|
|
6712
6746
|
let url = options.url;
|
|
6713
6747
|
if (!url) {
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6748
|
+
if (options.port) {
|
|
6749
|
+
const isServing = await testHttpPort(options.port);
|
|
6750
|
+
if (!isServing) {
|
|
6751
|
+
return {
|
|
6752
|
+
success: false,
|
|
6753
|
+
url: `http://localhost:${options.port}`,
|
|
6754
|
+
screenshots: [],
|
|
6755
|
+
error: `Port ${options.port} is not serving HTTP. Is your dev server running on this port?
|
|
6756
|
+
|
|
6757
|
+
Try:
|
|
6758
|
+
1. Verify your dev server is running: curl http://localhost:${options.port}
|
|
6759
|
+
2. Check if the port is correct
|
|
6760
|
+
3. Provide full URL: trie_visual_qa_browser url:"http://localhost:${options.port}"`,
|
|
6761
|
+
analysisPrompt: ""
|
|
6762
|
+
};
|
|
6763
|
+
}
|
|
6764
|
+
url = `http://localhost:${options.port}`;
|
|
6765
|
+
} else {
|
|
6766
|
+
if (!isInteractiveMode()) {
|
|
6767
|
+
console.error("\u{1F50D} Visual QA: Auto-detecting running dev server...");
|
|
6768
|
+
}
|
|
6769
|
+
const port = await findOpenPort();
|
|
6770
|
+
if (!port) {
|
|
6771
|
+
return {
|
|
6772
|
+
success: false,
|
|
6773
|
+
url: "",
|
|
6774
|
+
screenshots: [],
|
|
6775
|
+
error: 'No running dev server found on common ports (3000, 3001, 5173, 5174, 4200, 8080, 8000, 8888, 5000, 4000).\n\nPlease:\n1. Start your dev server, OR\n2. Provide a URL: trie_visual_qa_browser url:"http://localhost:3000", OR\n3. Specify a port: trie_visual_qa_browser port:3000',
|
|
6776
|
+
analysisPrompt: ""
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
url = `http://localhost:${port}`;
|
|
6780
|
+
if (!isInteractiveMode()) {
|
|
6781
|
+
console.error(` \u2713 Found server on port ${port}`);
|
|
6782
|
+
}
|
|
6723
6783
|
}
|
|
6724
|
-
url = `http://localhost:${port}`;
|
|
6725
6784
|
}
|
|
6726
6785
|
const viewports = options.viewports || DEFAULT_VIEWPORTS;
|
|
6727
6786
|
try {
|
|
@@ -6745,16 +6804,21 @@ async function runVisualQA(options = {}) {
|
|
|
6745
6804
|
};
|
|
6746
6805
|
} catch (error) {
|
|
6747
6806
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
6748
|
-
if (errorMessage.includes("net::ERR_CONNECTION_REFUSED")) {
|
|
6807
|
+
if (errorMessage.includes("net::ERR_CONNECTION_REFUSED") || errorMessage.includes("ECONNREFUSED")) {
|
|
6749
6808
|
return {
|
|
6750
6809
|
success: false,
|
|
6751
6810
|
url,
|
|
6752
6811
|
screenshots: [],
|
|
6753
|
-
error: `Cannot connect to ${url}. Is your dev server running
|
|
6812
|
+
error: `Cannot connect to ${url}. Is your dev server running?
|
|
6813
|
+
|
|
6814
|
+
Try:
|
|
6815
|
+
1. Start your dev server (e.g., npm start, npm run dev)
|
|
6816
|
+
2. Specify the URL explicitly: trie_visual_qa_browser url:"http://localhost:3000"
|
|
6817
|
+
3. Or specify the port: trie_visual_qa_browser port:3000`,
|
|
6754
6818
|
analysisPrompt: ""
|
|
6755
6819
|
};
|
|
6756
6820
|
}
|
|
6757
|
-
if (errorMessage.includes("Executable doesn't exist")) {
|
|
6821
|
+
if (errorMessage.includes("Executable doesn't exist") || errorMessage.includes("BrowserType")) {
|
|
6758
6822
|
return {
|
|
6759
6823
|
success: false,
|
|
6760
6824
|
url,
|
|
@@ -6763,11 +6827,30 @@ async function runVisualQA(options = {}) {
|
|
|
6763
6827
|
analysisPrompt: ""
|
|
6764
6828
|
};
|
|
6765
6829
|
}
|
|
6830
|
+
if (errorMessage.includes("timeout") || errorMessage.includes("Navigation timeout")) {
|
|
6831
|
+
return {
|
|
6832
|
+
success: false,
|
|
6833
|
+
url,
|
|
6834
|
+
screenshots: [],
|
|
6835
|
+
error: `Page load timeout for ${url}. The page may be taking too long to load or may have JavaScript errors.
|
|
6836
|
+
|
|
6837
|
+
Try:
|
|
6838
|
+
1. Check if the page loads in your browser
|
|
6839
|
+
2. Increase wait time: trie_visual_qa_browser url:"${url}" waitMs:5000
|
|
6840
|
+
3. Wait for specific element: trie_visual_qa_browser url:"${url}" waitForSelector:".main-content"`,
|
|
6841
|
+
analysisPrompt: ""
|
|
6842
|
+
};
|
|
6843
|
+
}
|
|
6766
6844
|
return {
|
|
6767
6845
|
success: false,
|
|
6768
6846
|
url,
|
|
6769
6847
|
screenshots: [],
|
|
6770
|
-
error: `Screenshot capture failed: ${errorMessage}
|
|
6848
|
+
error: `Screenshot capture failed: ${errorMessage}
|
|
6849
|
+
|
|
6850
|
+
Troubleshooting:
|
|
6851
|
+
1. Verify ${url} is accessible in your browser
|
|
6852
|
+
2. Check that your dev server is running
|
|
6853
|
+
3. Try specifying the URL explicitly: trie_visual_qa_browser url:"${url}"`,
|
|
6771
6854
|
analysisPrompt: ""
|
|
6772
6855
|
};
|
|
6773
6856
|
}
|
|
@@ -6930,8 +7013,46 @@ var RequestHandlers = class {
|
|
|
6930
7013
|
case "visual":
|
|
6931
7014
|
return await this.toolRegistry.getTool("agent").execute({ ...args, agent: "visual-qa" });
|
|
6932
7015
|
case "visual_qa_browser": {
|
|
6933
|
-
|
|
6934
|
-
|
|
7016
|
+
try {
|
|
7017
|
+
const result = await runVisualQA(args);
|
|
7018
|
+
return formatMCPResponse(result);
|
|
7019
|
+
} catch (error) {
|
|
7020
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7021
|
+
return {
|
|
7022
|
+
content: [{
|
|
7023
|
+
type: "text",
|
|
7024
|
+
text: `# Visual QA Error
|
|
7025
|
+
|
|
7026
|
+
Failed to capture screenshots: ${errorMessage}
|
|
7027
|
+
|
|
7028
|
+
## Troubleshooting
|
|
7029
|
+
|
|
7030
|
+
1. **Check if your dev server is running:**
|
|
7031
|
+
- Try accessing the URL in your browser
|
|
7032
|
+
- Common ports: 3000, 5173, 8080
|
|
7033
|
+
|
|
7034
|
+
2. **Specify the URL explicitly:**
|
|
7035
|
+
\`\`\`
|
|
7036
|
+
trie_visual_qa_browser url:"http://localhost:3000"
|
|
7037
|
+
\`\`\`
|
|
7038
|
+
|
|
7039
|
+
3. **Specify a port:**
|
|
7040
|
+
\`\`\`
|
|
7041
|
+
trie_visual_qa_browser port:3000
|
|
7042
|
+
\`\`\`
|
|
7043
|
+
|
|
7044
|
+
4. **Install Playwright browsers (if needed):**
|
|
7045
|
+
\`\`\`
|
|
7046
|
+
npx playwright install chromium
|
|
7047
|
+
\`\`\`
|
|
7048
|
+
|
|
7049
|
+
5. **Check for JavaScript errors:**
|
|
7050
|
+
- Open browser dev tools
|
|
7051
|
+
- Look for console errors
|
|
7052
|
+
- The page may be failing to load`
|
|
7053
|
+
}]
|
|
7054
|
+
};
|
|
7055
|
+
}
|
|
6935
7056
|
}
|
|
6936
7057
|
case "data_flow":
|
|
6937
7058
|
case "dataflow":
|
|
@@ -7132,15 +7253,15 @@ var MCPServer = class {
|
|
|
7132
7253
|
tools: this.toolRegistry.getAllTools()
|
|
7133
7254
|
};
|
|
7134
7255
|
});
|
|
7135
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (
|
|
7136
|
-
const { name, arguments: args } =
|
|
7256
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request2) => {
|
|
7257
|
+
const { name, arguments: args } = request2.params;
|
|
7137
7258
|
return await this.requestHandlers.handleToolCall(name, args);
|
|
7138
7259
|
});
|
|
7139
7260
|
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
7140
7261
|
return await this.requestHandlers.handleListResources();
|
|
7141
7262
|
});
|
|
7142
|
-
this.server.setRequestHandler(ReadResourceRequestSchema, async (
|
|
7143
|
-
const { uri } =
|
|
7263
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request2) => {
|
|
7264
|
+
const { uri } = request2.params;
|
|
7144
7265
|
return await this.requestHandlers.handleReadResource(uri);
|
|
7145
7266
|
});
|
|
7146
7267
|
}
|