using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function callTool(server, toolName, toolParams) { | |
let mcpSessionId = null; | |
try { | |
const response = await fetch(server, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
accept: "application/json text/event-stream", | |
}, | |
body: JSON.stringify({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const customCss = ` | |
shopify-product-card::part(product-title) { | |
font-weight: 600; | |
} | |
`; | |
iframe.contentWindow.postMessage({ | |
type: "ui-lifecycle-iframe-render-data", | |
payload: { | |
renderData: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>MCP-UI Proxy</title> | |
<style> | |
html, | |
body { | |
margin: 0; | |
height: 100vh; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="styles.css" /> | |
<meta | |
http-equiv="Content-Security-Policy" | |
content="frame-src http://localhost:3000" | |
/> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | |
import { createUIResource } from "@mcp-ui/server"; | |
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | |
const server = new McpServer({ | |
name: "mcp-ui-example", | |
version: "0.0.1", | |
}); | |
server.tool( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback , useState } from "react"; | |
import { UiActionResult, HtmlResource } from "@mcp-ui/client"; | |
function UIResponseWrapper({ addToChat, url }: { addToChat: (message: any) => void, url: string }) { | |
const [resourceStyle, setResourceStyle] = useState({ | |
height: "100px", | |
width: "100px", | |
}); | |
const handleUiAction = useCallback( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><body> | |
<script src="https://cdn.shopify.com/storefront/web-components.js"> | |
</script> | |
<!-- Provide the token and set the market context --> | |
<shopify-store store-domain="mock.shop" country="US" language="en"></shopify-store> | |
<div class="product-layout"> | |
<div class="product-card"> | |
<!-- Set product you want to display --> | |
<shopify-context type="product" handle="{{PRODUCT_ID}}"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.semanticHighlighting.enabled": false, | |
"editor.tokenColorCustomizations": { | |
"textMateRules": [ | |
{ | |
"scope": [ | |
"support.type.primitive.ts", | |
"entity.name.type.ts", | |
"meta.type.tuple.ts", | |
"meta.type.annotation.ts", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const resolve = (...args) => path.join(__dirname, ...args); | |
const lockedVersions = getPackageVersions(resolve('bower_components')); | |
const newBowerContents = buildNewBowerContents(lockedVersions); | |
console.log(`Writing to bower-lock.json`); | |
fs.writeFileSync(resolve('./bower-lock.json'), newBowerContents, 'utf8'); |
NewerOlder