GridStack MCP Server
Provides examples and integration patterns for implementing GridStack.js drag-and-drop grid layouts in Angular applications
Provides custom CSS examples and styling resources for GridStack.js grid layouts and widget components
Provides component-scoped styling integration for GridStack.js widgets using CSS Modules methodology
Provides comprehensive access to GridStack.js API through MCP tools for creating dynamic drag-and-drop grid layouts and interactive widget systems
Runs as a Node.js-based MCP server providing access to GridStack.js functionality through the Model Context Protocol
Distributed and managed as an npm package with dependencies installable through npm package manager
Provides examples, hooks, and integration patterns for implementing GridStack.js drag-and-drop grid layouts in React applications
Provides comprehensive Tailwind CSS integration for styling GridStack.js grids with utility-first CSS classes and custom grid column configurations
Provides full TypeScript support with detailed schemas and type definitions for GridStack.js API interactions
Supports Yarn package manager for dependency installation and project build processes
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GridStack MCP Server initialize a 12-column dashboard grid with auto cell height"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GridStack MCP Server
A comprehensive Model Context Protocol (MCP) server for GridStack.js - the powerful drag-and-drop grid layout library. This server provides complete access to GridStack's API through MCP tools and resources, making it easy to build dynamic dashboard layouts, responsive grids, and interactive widget systems.
š Features
Core GridStack Operations
Grid Management: Initialize, destroy, enable/disable grids
Widget Operations: Add, remove, update, move, resize widgets
Layout Control: Compact, float mode, column management
Responsive Design: Breakpoint configuration and responsive layouts
Serialization: Save and load grid layouts to/from JSON
Event Handling: Complete event system for grid interactions
Developer Experience
26+ Tools: Comprehensive coverage of GridStack API
Rich Resources: Examples, templates, and documentation
Framework Integration: React, Vue, Angular examples
CSS Support: Tailwind CSS and CSS modules integration
Type Safety: Full TypeScript support with detailed schemas
Related MCP server: @mcp-fe/react-tools
š¦ Installation
Prerequisites
Node.js 18+
npm or yarn
Setup
Clone the repository:
git clone <repository-url>
cd gridstack-mcp-serverInstall dependencies:
yarn install
# or
npm installBuild the project:
yarn build
# or
npm run buildšāāļø Running the Server
Local Development
# Build and start the server
yarn build && yarn start
# Development mode with auto-rebuild
yarn devMCP Client Integration
The server runs on stdio and follows the MCP protocol. Here's how to integrate it with different MCP clients:
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gridstack": {
"command": "node",
"args": ["/path/to/gridstack-mcp-server/dist/index.js"]
}
}
}Cursor/VSCode Integration
{
"mcp.servers": {
"gridstack": {
"command": "node",
"args": ["./dist/index.js"],
"cwd": "/path/to/gridstack-mcp-server"
}
}
}Testing the Server
Test with basic MCP commands:
# List available tools
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | node dist/index.js
# Initialize a grid
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "gridstack_init", "arguments": {"options": {"column": 12, "cellHeight": "auto"}}}}' | node dist/index.js
# List resources
echo '{"jsonrpc": "2.0", "id": 1, "method": "resources/list"}' | node dist/index.jsš Available Tools
Grid Management
Tool | Description |
| Initialize new GridStack instance |
| Destroy grid instance |
| Enable/disable grid interactions |
| Create grid with options and children |
Widget Operations
Tool | Description |
| Add new widget to grid |
| Remove widget from grid |
| Update widget properties |
| Move widget to new position |
| Resize widget dimensions |
| Convert DOM element to widget |
| Remove all widgets |
Layout Management
Tool | Description |
| Compact grid layout |
| Enable/disable floating mode |
| Change number of columns |
| Update cell height |
| Update grid margins |
| Batch multiple operations |
Data & State
Tool | Description |
| Save layout to JSON |
| Load layout from JSON |
| Get all grid items |
| Get current margins |
| Get column count |
| Get float state |
Utilities
Tool | Description |
| Check if widget fits |
| Check if area is empty |
| Get current cell height |
| Convert pixels to grid cells |
Events
Tool | Description |
| Add event listener |
| Remove event listener |
Responsive
Tool | Description |
| Configure breakpoints |
š Resources
The server provides several built-in resources:
gridstack://documentation/api- Complete API documentationgridstack://examples/basic- Basic GridStack implementationgridstack://examples/responsive- Responsive grid examplegridstack://examples/react- React integrationgridstack://examples/vue- Vue integrationgridstack://templates/dashboard- Dashboard templategridstack://css/custom- Custom CSS examples
š” Usage Examples
Basic Grid Initialization
// Initialize a 12-column grid with auto height
const grid = GridStack.init({
column: 12,
cellHeight: "auto",
margin: 10,
float: false,
});Adding Widgets
// Add a widget with specific position and size
grid.addWidget({
x: 0,
y: 0,
w: 3,
h: 2,
content: '<div class="my-widget">Content</div>',
id: "widget1",
});Responsive Configuration
// Set up responsive breakpoints
grid.setResponsive([
{ w: 768, c: 1 }, // Mobile: 1 column
{ w: 992, c: 6 }, // Tablet: 6 columns
{ w: 1200, c: 12 }, // Desktop: 12 columns
]);Save/Load Layout
// Save current layout
const layout = grid.save(true);
localStorage.setItem("dashboard-layout", JSON.stringify(layout));
// Load saved layout
const savedLayout = JSON.parse(localStorage.getItem("dashboard-layout"));
grid.load(savedLayout);šØ CSS Framework Support
Tailwind CSS Integration
The server includes comprehensive Tailwind CSS support for modern, utility-first styling:
Installation
# Install Tailwind CSS
npm install -D tailwindcss @tailwindcss/forms @tailwindcss/typography
npx tailwindcss initTailwind Configuration
// tailwind.config.js
module.exports = {
content: ["./src/**/*.{html,js,ts,jsx,tsx}"],
theme: {
extend: {
gridTemplateColumns: {
"gs-1": "repeat(1, minmax(0, 1fr))",
"gs-2": "repeat(2, minmax(0, 1fr))",
"gs-3": "repeat(3, minmax(0, 1fr))",
"gs-4": "repeat(4, minmax(0, 1fr))",
"gs-5": "repeat(5, minmax(0, 1fr))",
"gs-6": "repeat(6, minmax(0, 1fr))",
"gs-7": "repeat(7, minmax(0, 1fr))",
"gs-8": "repeat(8, minmax(0, 1fr))",
"gs-9": "repeat(9, minmax(0, 1fr))",
"gs-10": "repeat(10, minmax(0, 1fr))",
"gs-11": "repeat(11, minmax(0, 1fr))",
"gs-12": "repeat(12, minmax(0, 1fr))",
},
},
},
plugins: [],
};Tailwind GridStack Styles
/* Custom GridStack + Tailwind integration */
.grid-stack {
@apply relative;
}
.grid-stack-item {
@apply absolute transition-all duration-200 ease-in-out;
}
.grid-stack-item-content {
@apply h-full w-full rounded-lg border border-gray-200 bg-white p-4 shadow-sm hover:shadow-md;
}
.grid-stack-item-content.ui-draggable-dragging {
@apply shadow-lg ring-2 ring-blue-500 ring-opacity-50;
}
.grid-stack-item-content.ui-resizable-resizing {
@apply shadow-lg ring-2 ring-green-500 ring-opacity-50;
}
/* Responsive grid utilities */
.grid-stack-1 {
@apply grid-cols-gs-1;
}
.grid-stack-2 {
@apply grid-cols-gs-2;
}
.grid-stack-3 {
@apply grid-cols-gs-3;
}
.grid-stack-4 {
@apply grid-cols-gs-4;
}
.grid-stack-5 {
@apply grid-cols-gs-5;
}
.grid-stack-6 {
@apply grid-cols-gs-6;
}
.grid-stack-7 {
@apply grid-cols-gs-7;
}
.grid-stack-8 {
@apply grid-cols-gs-8;
}
.grid-stack-9 {
@apply grid-cols-gs-9;
}
.grid-stack-10 {
@apply grid-cols-gs-10;
}
.grid-stack-11 {
@apply grid-cols-gs-11;
}
.grid-stack-12 {
@apply grid-cols-gs-12;
}Tailwind Widget Components
<!-- Modern Dashboard Widget -->
<div class="grid-stack-item" gs-x="0" gs-y="0" gs-w="4" gs-h="3">
<div
class="grid-stack-item-content bg-gradient-to-br from-blue-50 to-indigo-100 border-indigo-200"
>
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-semibold text-gray-900">Sales Overview</h3>
<div class="flex space-x-2">
<button class="p-1 text-gray-400 hover:text-gray-600">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path
d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"
/>
</svg>
</button>
</div>
</div>
<div class="space-y-3">
<div class="flex justify-between items-center">
<span class="text-sm text-gray-600">This Month</span>
<span class="text-2xl font-bold text-indigo-600">$24,500</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div class="bg-indigo-600 h-2 rounded-full" style="width: 75%"></div>
</div>
<p class="text-sm text-green-600">ā +12% from last month</p>
</div>
</div>
</div>CSS Modules Integration
For component-scoped styling, the server supports CSS Modules:
CSS Module Example
/* Widget.module.css */
.widget {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 12px;
padding: 1.5rem;
color: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.2s ease-in-out;
}
.widget:hover {
transform: translateY(-2px);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}
.widgetHeader {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.widgetTitle {
font-size: 1.125rem;
font-weight: 600;
margin: 0;
}
.widgetValue {
font-size: 2rem;
font-weight: 700;
margin: 0.5rem 0;
}
.widgetChart {
flex: 1;
background: rgba(255, 255, 255, 0.1);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
min-height: 120px;
}React Component with CSS Modules
// Widget.jsx
import styles from "./Widget.module.css";
const Widget = ({ title, value, change, children }) => {
return (
<div className="grid-stack-item" gs-w="3" gs-h="2">
<div className={`grid-stack-item-content ${styles.widget}`}>
<div className={styles.widgetHeader}>
<h3 className={styles.widgetTitle}>{title}</h3>
</div>
<div className={styles.widgetValue}>{value}</div>
{change && <p className={styles.widgetChange}>{change}</p>}
{children && <div className={styles.widgetChart}>{children}</div>}
</div>
</div>
);
};š§ Advanced Configuration
Custom Widget Types
// Define custom widget templates
const widgetTemplates = {
chart: {
w: 4,
h: 3,
content: '<div class="chart-widget">Chart Content</div>',
minW: 2,
minH: 2,
},
kpi: {
w: 2,
h: 2,
content: '<div class="kpi-widget">KPI Content</div>',
noResize: true,
},
};
// Use templates
grid.addWidget(widgetTemplates.chart);Event Handling
// Listen to grid events
grid.on("change", (event, items) => {
console.log("Layout changed:", items);
// Auto-save layout
localStorage.setItem("layout", JSON.stringify(grid.save()));
});
grid.on("added", (event, items) => {
console.log("Widget added:", items);
});
grid.on("removed", (event, items) => {
console.log("Widget removed:", items);
});Performance Optimization
// Batch multiple operations
grid.batchUpdate(true);
grid.addWidget(widget1);
grid.addWidget(widget2);
grid.addWidget(widget3);
grid.batchUpdate(false); // Triggers single 'change' eventš Framework Integration
React Hook
import { useEffect, useRef, useState } from "react";
import { GridStack } from "gridstack";
export const useGridStack = (options = {}) => {
const gridRef = useRef(null);
const [grid, setGrid] = useState(null);
useEffect(() => {
if (gridRef.current) {
const gridInstance = GridStack.init(options, gridRef.current);
setGrid(gridInstance);
return () => gridInstance.destroy();
}
}, []);
return { gridRef, grid };
};Vue Composable
// useGridStack.js
import { ref, onMounted, onUnmounted } from "vue";
import { GridStack } from "gridstack";
export function useGridStack(options = {}) {
const gridRef = ref(null);
const grid = ref(null);
onMounted(() => {
if (gridRef.value) {
grid.value = GridStack.init(options, gridRef.value);
}
});
onUnmounted(() => {
grid.value?.destroy();
});
return { gridRef, grid };
}š API Reference
Tool Parameters
Each tool accepts specific parameters. Here are the most commonly used:
Widget Configuration
interface GridStackWidget {
id?: string | number;
x?: number; // X position (0-based)
y?: number; // Y position (0-based)
w?: number; // Width in columns
h?: number; // Height in rows
minW?: number; // Minimum width
maxW?: number; // Maximum width
minH?: number; // Minimum height
maxH?: number; // Maximum height
locked?: boolean; // Lock position/size
noResize?: boolean; // Disable resizing
noMove?: boolean; // Disable moving
content?: string; // HTML content
}Grid Options
interface GridStackOptions {
column?: number; // Number of columns (default: 12)
cellHeight?: number | string; // Cell height ('auto', px, etc.)
margin?: number | string; // Gap between items
float?: boolean; // Enable floating widgets
disableDrag?: boolean; // Disable dragging
disableResize?: boolean; // Disable resizing
animate?: boolean; // Enable animations
acceptWidgets?: boolean; // Accept external widgets
}š¤ Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Acknowledgments
GridStack.js - The amazing grid layout library
Model Context Protocol - The protocol this server implements
Anthropic - For the MCP specification and Claude integration
š Support
š Documentation
š Issue Tracker
š¬ Discussions
Happy Grid Building! šÆ
Available Tools
30 toolsgridstack_add_gridC
Create a new grid with options and children (static method)
Inputs: parent (required), opt.
gridstack_add_widgetC
Add a new widget to the grid
Inputs: widget (required), triggerAddEvent.
gridstack_batch_updateC
Enable/disable batch update mode for efficiency
Inputs: flag.
gridstack_cell_heightC
Update cell height
Inputs: val, update.
gridstack_columnC
Change the number of columns
Inputs: column (required), layout.
gridstack_compactC
Compact the grid layout
Inputs: layout, doSort.
gridstack_destroyC
Destroy the grid instance
Inputs: removeDOM.
gridstack_enableC
Enable or disable the grid
Inputs: doEnable.
gridstack_floatC
Enable or disable floating widgets
Inputs: val.
gridstack_get_cell_from_pixelC
Convert pixel coordinates to grid cell position
Inputs: position (required), useOffset.
gridstack_get_cell_heightC
Get current cell height
Inputs: no named parameters.
gridstack_get_columnB
Get current number of columns
Inputs: no named parameters.
gridstack_get_floatC
Get current float state
Inputs: no named parameters.
gridstack_get_grid_itemsC
Get all grid items
Inputs: onlyVisible.
gridstack_get_marginB
Get current margin values
Inputs: no named parameters.
gridstack_initC
Initialize a new GridStack instance with specified options
Inputs: selector, options.
gridstack_is_area_emptyC
Check if an area is empty
Inputs: x (required), y (required), w (required), h (required).
gridstack_loadC
Load grid layout from JSON
Inputs: layout (required), addAndRemove.
gridstack_make_widgetC
Convert an existing DOM element into a grid widget
Inputs: el (required), options.
gridstack_marginC
Update grid margin/gap
Inputs: value (required), unit.
gridstack_move_widgetC
Move a widget to a new position
Inputs: el (required), x, y.
gridstack_offC
Remove event listener
Inputs: eventName (required).
gridstack_onC
Add event listener
Inputs: eventName (required), callback (required).
gridstack_remove_allC
Remove all widgets from the grid
Inputs: removeDOM.
gridstack_remove_widgetC
Remove a widget from the grid
Inputs: el (required), removeDOM, triggerEvent.
gridstack_resize_widgetC
Resize a widget
Inputs: el (required), width, height.
gridstack_saveC
Save grid layout to JSON
Inputs: saveContent, saveGridOpt.
gridstack_set_responsiveC
Configure responsive breakpoints
Inputs: breakpoints (required).
gridstack_update_widgetC
Update widget properties
Inputs: el (required), opts (required).
gridstack_will_it_fitC
Check if a widget will fit at specified position
Inputs: widget (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 30 tools
Most tools have distinct purposes, but some overlap exists, such as 'gridstack_init' and 'gridstack_add_grid' both creating grids, and 'gridstack_get_*' tools being similar in retrieval function. Descriptions help clarify differences, but minor confusion could occur in selection.
All tools follow a consistent 'gridstack_verb_noun' pattern with snake_case, making them predictable and readable. The naming convention is uniform across all 30 tools, enhancing usability and reducing cognitive load.
With 30 tools, the count is high and feels heavy for a grid management server, potentially overwhelming agents. While the domain is comprehensive, many tools could be consolidated or omitted without losing functionality, indicating an excessive scope.
The tool set provides complete coverage for grid management, including CRUD operations (add, remove, update), configuration (init, enable, destroy), layout handling (save, load, compact), and utility functions (check fit, convert coordinates). No obvious gaps exist for the stated purpose.
Maintenance
Related MCP Connectors
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
- ChartPaneDeprecatedcom.chartpane.mcp
Renders interactive Chart.js charts and dashboards inline in AI conversations. Supports bar, line, area, pie, doughnut, scatter, and radar charts with multi-chart dashboard grids.
Dashboards as data. Author, validate, render, and share dvt dashboards from any MCP client.
Free deterministic tools for math, data transforms, dates, text, statistics, finance, and units.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables comprehensive management of Directus instances through tools for schema manipulation, content CRUD operations, and dashboard management. It allows AI assistants to programmatically interact with collections, fields, relations, and workflow automation using the official Directus SDK.2020 npmMIT
- AlicenseNot gradedqualityCmaintenanceDon't let AI guess from screenshots. Give LLMs direct access to your React state, Context, and Data Grids. Features bidirectional communication via SharedWorkers & WebSockets. Docker gateway included.15Apache 2.0
- AlicenseNot gradedqualityDmaintenanceProvides comprehensive programmatic control over Google Workspace applications including Sheets, Docs, Drive, Gmail, Calendar, and Slides with 141 tools for automation and management.582 npm3Elastic 2.0
- AlicenseNot gradedqualityDmaintenanceProvides complete browser automation capabilities for AI agents via 44 tools, including navigation, element interaction, state management, and session recording.81 npm1Apache 2.0