ubiquitous-invention/apps/mcp-server/src/resources/view-resource.ts
Randall Stillwell a508ece6e7 feat: Full project management application scaffold
Complete architecture for a ClickUp/Notion/Miro-class project management app:

- Turborepo monorepo with Next.js 15, TypeScript, PostgreSQL (Drizzle ORM)
- Object-centered database schema (everything is an Object: tasks, projects, docs, whiteboards)
- NextAuth v5 authentication with credentials + OAuth providers
- tRPC v11 API layer with full CRUD for objects, properties, relations, templates, search
- Three-panel UI: collapsible sidebar, center content area, push-in right panel
- Purple/teal theme with light/dark mode via Shadcn/ui + Tailwind CSS
- Multiple views: List, Kanban board (dnd-kit), Table (spreadsheet), Embedded iframe
- TipTap rich text editor with slash commands, custom blocks (callout, toggle, mention, embed, divider), AI block
- Real-time collaboration via Yjs + Hocuspocus with presence/cursors
- tldraw whiteboard with custom shape cards (task, document, project)
- MCP server exposing all app data/tools for AI agents
- AI chat panel, editor AI slash commands, Cmd+K command palette
- Template system with built-in templates (Bug Report, Meeting Notes, Sprint)
- Full-text search with result highlighting
- Docker Compose for full-stack deployment (web + collab + postgres + redis)

Made-with: Cursor
2026-03-26 22:39:16 -05:00

82 lines
2 KiB
TypeScript

import { ResourceTemplate, type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { eq } from "../drizzle.js";
import { db } from "../db.js";
import { views } from "../schema.js";
export function registerViewResource(mcp: McpServer): void {
mcp.registerResource(
"view",
new ResourceTemplate("view://{id}", { list: undefined }),
{
description: "View configuration, metadata, and parent object summary.",
mimeType: "application/json",
},
async (uri, variables) => {
const id = variables.id;
if (!id) {
return {
contents: [
{
uri: uri.toString(),
mimeType: "application/json",
text: JSON.stringify({ error: "Missing view id" }),
},
],
};
}
const view = await db.query.views.findFirst({
where: eq(views.id, id),
with: {
object: true,
},
});
if (!view) {
return {
contents: [
{
uri: uri.toString(),
mimeType: "application/json",
text: JSON.stringify({ error: "View not found", id }),
},
],
};
}
const parent = view.object;
const objectSummary =
parent && !Array.isArray(parent)
? {
id: parent.id,
title: parent.title,
type: parent.type,
}
: null;
const payload = {
view: {
id: view.id,
objectId: view.objectId,
viewType: view.viewType,
name: view.name,
config: view.config,
sortOrder: view.sortOrder,
createdAt: view.createdAt,
updatedAt: view.updatedAt,
},
object: objectSummary,
};
return {
contents: [
{
uri: uri.toString(),
mimeType: "application/json",
text: JSON.stringify(payload, null, 2),
},
],
};
},
);
}