chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
import type { MongoDBDeleteParams, MongoDBResponse } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const deleteTool: ToolConfig<MongoDBDeleteParams, MongoDBResponse> = {
|
||||
id: 'mongodb_delete',
|
||||
name: 'MongoDB Delete',
|
||||
description: 'Delete documents from MongoDB collection',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Database name to connect to (e.g., "mydb")',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
collection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Collection name to delete from',
|
||||
},
|
||||
filter: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Filter criteria as JSON string',
|
||||
},
|
||||
multi: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Delete multiple documents',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/delete',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
collection: params.collection,
|
||||
filter: params.filter,
|
||||
multi: params.multi || false,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB delete failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Documents deleted successfully',
|
||||
deletedCount: data.deletedCount || 0,
|
||||
documentCount: data.documentCount || 0,
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
deletedCount: { type: 'number', description: 'Number of documents deleted' },
|
||||
documentCount: { type: 'number', description: 'Total number of documents affected' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import type { MongoDBExecuteParams, MongoDBResponse } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const executeTool: ToolConfig<MongoDBExecuteParams, MongoDBResponse> = {
|
||||
id: 'mongodb_execute',
|
||||
name: 'MongoDB Execute',
|
||||
description: 'Execute MongoDB aggregation pipeline',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Database name to connect to (e.g., "mydb")',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
collection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Collection name to execute pipeline on',
|
||||
},
|
||||
pipeline: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Aggregation pipeline as JSON string',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/execute',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
collection: params.collection,
|
||||
pipeline: params.pipeline,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB aggregation failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Aggregation executed successfully',
|
||||
documents: data.documents || [],
|
||||
documentCount: data.documentCount || 0,
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
documents: { type: 'array', description: 'Array of documents returned from aggregation' },
|
||||
documentCount: { type: 'number', description: 'Number of documents returned' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { deleteTool } from './delete'
|
||||
import { executeTool } from './execute'
|
||||
import { insertTool } from './insert'
|
||||
import { introspectTool } from './introspect'
|
||||
import { queryTool } from './query'
|
||||
import { updateTool } from './update'
|
||||
|
||||
export const mongodbDeleteTool = deleteTool
|
||||
export const mongodbExecuteTool = executeTool
|
||||
export const mongodbInsertTool = insertTool
|
||||
export const mongodbIntrospectTool = introspectTool
|
||||
export const mongodbQueryTool = queryTool
|
||||
export const mongodbUpdateTool = updateTool
|
||||
|
||||
export * from './types'
|
||||
@@ -0,0 +1,111 @@
|
||||
import type { MongoDBInsertParams, MongoDBResponse } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const insertTool: ToolConfig<MongoDBInsertParams, MongoDBResponse> = {
|
||||
id: 'mongodb_insert',
|
||||
name: 'MongoDB Insert',
|
||||
description: 'Insert documents into MongoDB collection',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Database name to connect to (e.g., "mydb")',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
collection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Collection name to insert into',
|
||||
},
|
||||
documents: {
|
||||
type: 'array',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Array of documents to insert',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/insert',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
collection: params.collection,
|
||||
documents: params.documents,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB insert failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Documents inserted successfully',
|
||||
documentCount: data.documentCount || 0,
|
||||
insertedId: data.insertedId,
|
||||
insertedIds: data.insertedIds,
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
documentCount: { type: 'number', description: 'Number of documents inserted' },
|
||||
insertedId: { type: 'string', description: 'ID of inserted document (single insert)' },
|
||||
insertedIds: { type: 'array', description: 'Array of inserted document IDs (multiple insert)' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import type { MongoDBIntrospectParams, MongoDBIntrospectResponse } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const introspectTool: ToolConfig<MongoDBIntrospectParams, MongoDBIntrospectResponse> = {
|
||||
id: 'mongodb_introspect',
|
||||
name: 'MongoDB Introspect',
|
||||
description: 'Introspect MongoDB database to list databases, collections, and indexes',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Database name to introspect (e.g., "mydb"). If not provided, lists all databases',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/introspect',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB introspect failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Introspection completed successfully',
|
||||
databases: data.databases || [],
|
||||
collections: data.collections || [],
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
databases: { type: 'array', description: 'Array of database names' },
|
||||
collections: {
|
||||
type: 'array',
|
||||
description: 'Array of collection info with name, type, document count, and indexes',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import type { MongoDBQueryParams, MongoDBResponse } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const queryTool: ToolConfig<MongoDBQueryParams, MongoDBResponse> = {
|
||||
id: 'mongodb_query',
|
||||
name: 'MongoDB Query',
|
||||
description: 'Execute find operation on MongoDB collection',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Database name to connect to (e.g., "mydb")',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
collection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Collection name to query',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'MongoDB query filter as JSON string',
|
||||
},
|
||||
limit: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Maximum number of documents to return',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Sort criteria as JSON string',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/query',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
collection: params.collection,
|
||||
query: params.query,
|
||||
limit: params.limit ? Number(params.limit) : undefined,
|
||||
sort: params.sort,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB query failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Query executed successfully',
|
||||
documents: data.documents || [],
|
||||
documentCount: data.documentCount || 0,
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
documents: { type: 'array', description: 'Array of documents returned from the query' },
|
||||
documentCount: { type: 'number', description: 'Number of documents returned' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
export interface MongoDBConnectionConfig {
|
||||
host: string
|
||||
port: number
|
||||
database: string
|
||||
username?: string
|
||||
password?: string
|
||||
authSource?: string
|
||||
ssl?: 'disabled' | 'required' | 'preferred'
|
||||
}
|
||||
|
||||
export interface MongoDBQueryParams extends MongoDBConnectionConfig {
|
||||
collection: string
|
||||
query?: string
|
||||
limit?: number
|
||||
sort?: string
|
||||
}
|
||||
|
||||
export interface MongoDBInsertParams extends MongoDBConnectionConfig {
|
||||
collection: string
|
||||
documents: unknown[]
|
||||
}
|
||||
|
||||
export interface MongoDBUpdateParams extends MongoDBConnectionConfig {
|
||||
collection: string
|
||||
filter: string
|
||||
update: string
|
||||
upsert?: boolean
|
||||
multi?: boolean
|
||||
}
|
||||
|
||||
export interface MongoDBDeleteParams extends MongoDBConnectionConfig {
|
||||
collection: string
|
||||
filter: string
|
||||
multi?: boolean
|
||||
}
|
||||
|
||||
export interface MongoDBExecuteParams extends MongoDBConnectionConfig {
|
||||
collection: string
|
||||
pipeline: string
|
||||
}
|
||||
|
||||
export interface MongoDBIntrospectParams {
|
||||
host: string
|
||||
port: number
|
||||
database?: string
|
||||
username?: string
|
||||
password?: string
|
||||
authSource?: string
|
||||
ssl?: 'disabled' | 'required' | 'preferred'
|
||||
}
|
||||
|
||||
export interface MongoDBCollectionInfo {
|
||||
name: string
|
||||
type: string
|
||||
documentCount: number
|
||||
indexes: Array<{
|
||||
name: string
|
||||
key: Record<string, number>
|
||||
unique: boolean
|
||||
sparse?: boolean
|
||||
}>
|
||||
}
|
||||
|
||||
interface MongoDBBaseResponse extends ToolResponse {
|
||||
output: {
|
||||
message: string
|
||||
documents?: unknown[]
|
||||
documentCount: number
|
||||
insertedId?: string
|
||||
insertedIds?: string[]
|
||||
modifiedCount?: number
|
||||
deletedCount?: number
|
||||
matchedCount?: number
|
||||
}
|
||||
error?: string
|
||||
}
|
||||
|
||||
interface MongoDBQueryResponse extends MongoDBBaseResponse {}
|
||||
interface MongoDBInsertResponse extends MongoDBBaseResponse {}
|
||||
interface MongoDBUpdateResponse extends MongoDBBaseResponse {}
|
||||
interface MongoDBDeleteResponse extends MongoDBBaseResponse {}
|
||||
interface MongoDBExecuteResponse extends MongoDBBaseResponse {}
|
||||
export interface MongoDBResponse extends MongoDBBaseResponse {}
|
||||
|
||||
export interface MongoDBIntrospectResponse extends ToolResponse {
|
||||
output: {
|
||||
message: string
|
||||
databases: string[]
|
||||
collections: MongoDBCollectionInfo[]
|
||||
}
|
||||
error?: string
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import type { MongoDBResponse, MongoDBUpdateParams } from '@/tools/mongodb/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const updateTool: ToolConfig<MongoDBUpdateParams, MongoDBResponse> = {
|
||||
id: 'mongodb_update',
|
||||
name: 'MongoDB Update',
|
||||
description: 'Update documents in MongoDB collection',
|
||||
version: '1.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server hostname or IP address',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB server port (default: 27017)',
|
||||
},
|
||||
database: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Database name to connect to (e.g., "mydb")',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB username',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'MongoDB password',
|
||||
},
|
||||
authSource: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Authentication database',
|
||||
},
|
||||
ssl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'SSL connection mode (disabled, required, preferred)',
|
||||
},
|
||||
collection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Collection name to update',
|
||||
},
|
||||
filter: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Filter criteria as JSON string',
|
||||
},
|
||||
update: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Update operations as JSON string',
|
||||
},
|
||||
upsert: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Create document if not found',
|
||||
},
|
||||
multi: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Update multiple documents',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/tools/mongodb/update',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
host: params.host,
|
||||
port: Number(params.port),
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
authSource: params.authSource,
|
||||
ssl: params.ssl || 'preferred',
|
||||
collection: params.collection,
|
||||
filter: params.filter,
|
||||
update: params.update,
|
||||
upsert: params.upsert || false,
|
||||
multi: params.multi || false,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'MongoDB update failed')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data.message || 'Documents updated successfully',
|
||||
matchedCount: data.matchedCount || 0,
|
||||
modifiedCount: data.modifiedCount || 0,
|
||||
documentCount: data.documentCount || 0,
|
||||
insertedId: data.insertedId,
|
||||
},
|
||||
error: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
message: { type: 'string', description: 'Operation status message' },
|
||||
matchedCount: { type: 'number', description: 'Number of documents matched by filter' },
|
||||
modifiedCount: { type: 'number', description: 'Number of documents modified' },
|
||||
documentCount: { type: 'number', description: 'Total number of documents affected' },
|
||||
insertedId: { type: 'string', description: 'ID of inserted document (if upsert)' },
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user