@wireweave/mcp-server 1.4.0 → 1.5.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/README.md +4 -0
- package/dist/index.js +178 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/@wireweave/mcp-server"><img src="https://img.shields.io/npm/v/@wireweave/mcp-server.svg" alt="npm version"></a>
|
|
9
9
|
<a href="https://github.com/wireweave/mcp-server/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@wireweave/mcp-server.svg" alt="license"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@wireweave/mcp-server"><img src="https://img.shields.io/npm/dm/@wireweave/mcp-server.svg" alt="npm downloads"></a>
|
|
11
|
+
<a href="https://lobehub.com/mcp/wireweave-mcp-server"><img src="https://lobehub.com/badge/mcp/wireweave-mcp-server" alt="LobeHub MCP"></a>
|
|
12
|
+
<a href="https://mcpserverhub.com"><img src="https://img.shields.io/badge/MCP-Server%20Hub-blue" alt="MCP Server Hub"></a>
|
|
13
|
+
<a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-Compatible-green" alt="MCP Compatible"></a>
|
|
10
14
|
</p>
|
|
11
15
|
|
|
12
16
|
<p align="center">Model Context Protocol server for Wireweave DSL - AI-powered wireframe generation</p>
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,11 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
6
|
import {
|
|
7
7
|
CallToolRequestSchema,
|
|
8
|
-
ListToolsRequestSchema
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
|
+
ListPromptsRequestSchema,
|
|
10
|
+
GetPromptRequestSchema,
|
|
11
|
+
ListResourcesRequestSchema,
|
|
12
|
+
ReadResourceRequestSchema
|
|
9
13
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
10
14
|
|
|
11
15
|
// src/tools.ts
|
|
@@ -705,6 +709,109 @@ var toolEndpoints = {
|
|
|
705
709
|
wireweave_gallery: { method: "GET", path: "/cloud/gallery" }
|
|
706
710
|
};
|
|
707
711
|
|
|
712
|
+
// src/prompts.ts
|
|
713
|
+
var prompts = [
|
|
714
|
+
{
|
|
715
|
+
name: "create_wireframe",
|
|
716
|
+
description: "Create a new wireframe from a natural language description. Generates Wireweave DSL code.",
|
|
717
|
+
arguments: [
|
|
718
|
+
{
|
|
719
|
+
name: "description",
|
|
720
|
+
description: 'Description of the wireframe to create (e.g., "login page with email and password fields")',
|
|
721
|
+
required: true
|
|
722
|
+
}
|
|
723
|
+
]
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "improve_ux",
|
|
727
|
+
description: "Analyze existing wireframe code and suggest UX improvements based on best practices.",
|
|
728
|
+
arguments: [
|
|
729
|
+
{
|
|
730
|
+
name: "code",
|
|
731
|
+
description: "Wireweave DSL code to analyze",
|
|
732
|
+
required: true
|
|
733
|
+
}
|
|
734
|
+
]
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: "convert_to_wireframe",
|
|
738
|
+
description: "Convert a UI description or sketch concept into Wireweave DSL code.",
|
|
739
|
+
arguments: [
|
|
740
|
+
{
|
|
741
|
+
name: "ui_description",
|
|
742
|
+
description: "Detailed description of the UI layout and components",
|
|
743
|
+
required: true
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
name: "style",
|
|
747
|
+
description: "Optional style preference (minimal, detailed, mobile-first)",
|
|
748
|
+
required: false
|
|
749
|
+
}
|
|
750
|
+
]
|
|
751
|
+
}
|
|
752
|
+
];
|
|
753
|
+
var promptTemplates = {
|
|
754
|
+
"create_wireframe": `Create a Wireweave DSL wireframe for: {{description}}
|
|
755
|
+
|
|
756
|
+
Please use the wireweave_guide tool first to understand the DSL syntax, then generate valid Wireweave code.
|
|
757
|
+
After generating, use wireweave_validate to check the syntax and wireweave_validate_ux to check UX best practices.`,
|
|
758
|
+
"improve_ux": `Analyze and improve the UX of this Wireweave wireframe:
|
|
759
|
+
|
|
760
|
+
\`\`\`wireframe
|
|
761
|
+
{{code}}
|
|
762
|
+
\`\`\`
|
|
763
|
+
|
|
764
|
+
Please use wireweave_validate_ux to get specific recommendations, then suggest improvements.`,
|
|
765
|
+
"convert_to_wireframe": `Convert this UI description to Wireweave DSL code:
|
|
766
|
+
|
|
767
|
+
{{ui_description}}
|
|
768
|
+
|
|
769
|
+
Style preference: {{style}}
|
|
770
|
+
|
|
771
|
+
Use wireweave_guide for syntax reference and wireweave_patterns for common layouts.`
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// src/resources.ts
|
|
775
|
+
var resources = [
|
|
776
|
+
{
|
|
777
|
+
uri: "wireweave://grammar",
|
|
778
|
+
name: "Complete grammar reference for Wireweave DSL syntax and structure",
|
|
779
|
+
description: "Complete grammar reference for Wireweave DSL syntax and structure",
|
|
780
|
+
mimeType: "text/markdown"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
uri: "wireweave://guide",
|
|
784
|
+
name: "Comprehensive guide for writing Wireweave DSL code, including best practices",
|
|
785
|
+
description: "Comprehensive guide for writing Wireweave DSL code, including best practices",
|
|
786
|
+
mimeType: "text/markdown"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
uri: "wireweave://examples",
|
|
790
|
+
name: "Collection of example wireframe codes for common UI patterns",
|
|
791
|
+
description: "Collection of example wireframe codes for common UI patterns",
|
|
792
|
+
mimeType: "text/markdown"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
uri: "wireweave://patterns",
|
|
796
|
+
name: "Common layout patterns and templates for wireframes",
|
|
797
|
+
description: "Common layout patterns and templates for wireframes",
|
|
798
|
+
mimeType: "text/markdown"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
uri: "wireweave://ux-rules",
|
|
802
|
+
name: "UX validation rules and best practices for wireframe design",
|
|
803
|
+
description: "UX validation rules and best practices for wireframe design",
|
|
804
|
+
mimeType: "text/markdown"
|
|
805
|
+
}
|
|
806
|
+
];
|
|
807
|
+
var resourceToTool = {
|
|
808
|
+
"wireweave://grammar": "wireweave_grammar",
|
|
809
|
+
"wireweave://guide": "wireweave_guide",
|
|
810
|
+
"wireweave://examples": "wireweave_examples",
|
|
811
|
+
"wireweave://patterns": "wireweave_patterns",
|
|
812
|
+
"wireweave://ux-rules": "wireweave_ux_rules"
|
|
813
|
+
};
|
|
814
|
+
|
|
708
815
|
// src/api.ts
|
|
709
816
|
function buildRequest(config, endpoint, args) {
|
|
710
817
|
let path = endpoint.path;
|
|
@@ -804,7 +911,9 @@ var server = new Server(
|
|
|
804
911
|
},
|
|
805
912
|
{
|
|
806
913
|
capabilities: {
|
|
807
|
-
tools: {}
|
|
914
|
+
tools: {},
|
|
915
|
+
prompts: {},
|
|
916
|
+
resources: {}
|
|
808
917
|
}
|
|
809
918
|
}
|
|
810
919
|
);
|
|
@@ -852,6 +961,72 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
852
961
|
};
|
|
853
962
|
}
|
|
854
963
|
});
|
|
964
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
965
|
+
return { prompts };
|
|
966
|
+
});
|
|
967
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
968
|
+
const { name, arguments: args } = request.params;
|
|
969
|
+
const prompt = prompts.find((p) => p.name === name);
|
|
970
|
+
if (!prompt) {
|
|
971
|
+
throw new Error(`Prompt not found: ${name}`);
|
|
972
|
+
}
|
|
973
|
+
const template = promptTemplates[name];
|
|
974
|
+
if (!template) {
|
|
975
|
+
throw new Error(`Prompt template not found: ${name}`);
|
|
976
|
+
}
|
|
977
|
+
let messageText = template;
|
|
978
|
+
if (args) {
|
|
979
|
+
for (const [key, value] of Object.entries(args)) {
|
|
980
|
+
messageText = messageText.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), String(value));
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
messageText = messageText.replace(/\{\{[^}]+\}\}/g, "");
|
|
984
|
+
return {
|
|
985
|
+
description: prompt.description,
|
|
986
|
+
messages: [
|
|
987
|
+
{
|
|
988
|
+
role: "user",
|
|
989
|
+
content: {
|
|
990
|
+
type: "text",
|
|
991
|
+
text: messageText
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
};
|
|
996
|
+
});
|
|
997
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
998
|
+
return { resources };
|
|
999
|
+
});
|
|
1000
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
1001
|
+
const { uri } = request.params;
|
|
1002
|
+
const resource = resources.find((r) => r.uri === uri);
|
|
1003
|
+
if (!resource) {
|
|
1004
|
+
throw new Error(`Resource not found: ${uri}`);
|
|
1005
|
+
}
|
|
1006
|
+
const toolName = resourceToTool[uri];
|
|
1007
|
+
if (!toolName) {
|
|
1008
|
+
throw new Error(`No tool mapping for resource: ${uri}`);
|
|
1009
|
+
}
|
|
1010
|
+
const endpoint = toolEndpoints[toolName];
|
|
1011
|
+
if (!endpoint) {
|
|
1012
|
+
throw new Error(`Tool endpoint not found: ${toolName}`);
|
|
1013
|
+
}
|
|
1014
|
+
try {
|
|
1015
|
+
const result = await callApi(apiConfig, endpoint, {});
|
|
1016
|
+
const content = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
1017
|
+
return {
|
|
1018
|
+
contents: [
|
|
1019
|
+
{
|
|
1020
|
+
uri,
|
|
1021
|
+
mimeType: resource.mimeType,
|
|
1022
|
+
text: content
|
|
1023
|
+
}
|
|
1024
|
+
]
|
|
1025
|
+
};
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
throw new Error(`Failed to fetch resource: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
855
1030
|
server.onerror = (error) => {
|
|
856
1031
|
log("An error occurred", "error");
|
|
857
1032
|
};
|
|
@@ -862,7 +1037,7 @@ process.on("SIGINT", async () => {
|
|
|
862
1037
|
async function main() {
|
|
863
1038
|
const transport = new StdioServerTransport();
|
|
864
1039
|
await server.connect(transport);
|
|
865
|
-
log(`MCP server started with ${tools.length} tools`);
|
|
1040
|
+
log(`MCP server started with ${tools.length} tools, ${prompts.length} prompts, ${resources.length} resources`);
|
|
866
1041
|
if (!API_KEY) {
|
|
867
1042
|
log("API key not configured. Get one at https://dashboard.wireweave.org", "warn");
|
|
868
1043
|
}
|