Skip to content

Commit 330678d

Browse files
authored
Merge pull request #550 from objectstack-ai/copilot/define-mcp-protocols
2 parents 636f006 + 122a829 commit 330678d

52 files changed

Lines changed: 5512 additions & 29 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/spec/PROTOCOL_MAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ This document serves as the **Grand Map** of the ObjectStack specification. It l
7575
| :--- | :--- | :--- |
7676
| [`agent.zod.ts`](src/ai/agent.zod.ts) || **AI Agent**. Attributes of an AI assistant (role, personality, model). |
7777
| [`agent-action.zod.ts`](src/ai/agent-action.zod.ts) || **Tools & Actions**. Capabilities exposed to the AI (Function Calling). |
78+
| [`mcp.zod.ts`](src/ai/mcp.zod.ts) || **Model Context Protocol (MCP)**. Standard protocol for connecting AI to tools, resources, and data sources. |
7879
| [`rag-pipeline.zod.ts`](src/ai/rag-pipeline.zod.ts) || **RAG**. Retrieval Augmented Generation configurations. |
7980
| [`model-registry.zod.ts`](src/ai/model-registry.zod.ts) | | **LLM Registry**. Configuration for model providers (OpenAI, Anthropic). |
8081
| [`conversation.zod.ts`](src/ai/conversation.zod.ts) | | **Chat Session**. History and context management for AI chats. |

packages/spec/README.md

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The **Source of Truth** for the ObjectStack Protocol. Contains strictly typed Zo
88
- **Data**: Objects, Fields, Validation Rules.
99
- **UI**: Views, Layouts, Dashboards.
1010
- **Automation**: Flows, Workflows, Triggers.
11-
- **AI**: Agents, RAG Pipelines, Models.
11+
- **AI**: Agents, RAG Pipelines, Models, MCP Servers.
1212

1313
## Usage
1414

@@ -58,3 +58,133 @@ if (result.success) {
5858
console.log('Valid object:', result.data);
5959
}
6060
```
61+
62+
## MCP (Model Context Protocol) Integration
63+
64+
Define MCP servers to connect AI agents to your ObjectStack data and tools:
65+
66+
```typescript
67+
import { MCPServerConfigSchema } from '@objectstack/spec/ai';
68+
69+
// Define an MCP server exposing ObjectStack data
70+
export const objectStackMCP = MCPServerConfigSchema.parse({
71+
name: 'objectstack_mcp',
72+
label: 'ObjectStack MCP Server',
73+
description: 'Connects AI agents to ObjectStack data and workflows',
74+
75+
serverInfo: {
76+
name: 'ObjectStack MCP',
77+
version: '1.0.0',
78+
capabilities: {
79+
resources: true,
80+
resourceTemplates: true,
81+
tools: true,
82+
prompts: true,
83+
},
84+
},
85+
86+
transport: {
87+
type: 'http',
88+
url: 'https://api.objectstack.ai/mcp',
89+
auth: {
90+
type: 'bearer',
91+
secretRef: 'system:mcp_api_key',
92+
},
93+
},
94+
95+
// Expose data as resources
96+
resourceTemplates: [
97+
{
98+
uriPattern: 'objectstack://objects/{objectName}',
99+
name: 'Object Data',
100+
description: 'Access object records',
101+
parameters: [
102+
{
103+
name: 'objectName',
104+
type: 'string',
105+
required: true,
106+
description: 'Name of the object to access',
107+
},
108+
],
109+
handler: 'resources.getObjectData',
110+
},
111+
],
112+
113+
// Expose workflows as tools
114+
tools: [
115+
{
116+
name: 'create_record',
117+
description: 'Create a new record in any object',
118+
parameters: [
119+
{
120+
name: 'object',
121+
type: 'string',
122+
description: 'Object name (e.g., "account", "contact")',
123+
required: true,
124+
},
125+
{
126+
name: 'data',
127+
type: 'object',
128+
description: 'Record data as key-value pairs',
129+
required: true,
130+
},
131+
],
132+
handler: 'flows.create_record',
133+
sideEffects: 'write',
134+
requiresConfirmation: true,
135+
},
136+
{
137+
name: 'search_records',
138+
description: 'Search for records using natural language or filters',
139+
parameters: [
140+
{
141+
name: 'object',
142+
type: 'string',
143+
description: 'Object to search in',
144+
required: true,
145+
},
146+
{
147+
name: 'query',
148+
type: 'string',
149+
description: 'Search query',
150+
required: true,
151+
},
152+
],
153+
handler: 'data.search',
154+
sideEffects: 'read',
155+
},
156+
],
157+
158+
// Provide prompt templates
159+
prompts: [
160+
{
161+
name: 'analyze_customer_data',
162+
description: 'Analyze customer data and generate insights',
163+
messages: [
164+
{
165+
role: 'system',
166+
content: 'You are a data analyst specializing in customer insights.',
167+
},
168+
{
169+
role: 'user',
170+
content: 'Analyze the following customer data and provide insights: {{customer_data}}',
171+
},
172+
],
173+
arguments: [
174+
{
175+
name: 'customer_data',
176+
type: 'string',
177+
required: true,
178+
description: 'Customer data in JSON format',
179+
},
180+
],
181+
},
182+
],
183+
184+
autoStart: true,
185+
healthCheck: {
186+
enabled: true,
187+
interval: 60000,
188+
},
189+
});
190+
```

0 commit comments

Comments
 (0)