mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 10:46:53 +00:00
feat: move MCP to /mcp and add teammate operations (#500)
* feat(operations): move MCP to /mcp and add search, comment, metadata, version, and upload operations - Serve the MCP server at /mcp instead of /api/mcp - Add search_assets, copy_assets, get_folder_instructions, list_comments, create_comment, resolve_comment, list_metadata_fields, update_asset_metadata, create_version_stack, list_versions, and remove_version on the agent, MCP, and CLI - Add create_file and create_version (agent, MCP) with Creation Context metadata, and complete_upload (MCP) for presigned two-step uploads - Replace the native agent create_file/create_version tools with Operation-backed ones - Route the comment-complete, metadata, copy, version stack, and AGENTS.md read REST endpoints through their Operations * docs(readme): add built-in MCP server and CLI to features list
This commit is contained in:
@@ -6,7 +6,12 @@ import { searchService } from '@shumai/core/src/search/search'
|
||||
import { authzService, ResourceType, Permission } from '@shumai/core/src/authz/authz'
|
||||
import { authMiddleware } from './middleware/auth'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import { createFolderOp, renameAssetOp, runOperation } from '@shumai/core/src/operations'
|
||||
import {
|
||||
createFolderOp,
|
||||
getFolderInstructionsOp,
|
||||
renameAssetOp,
|
||||
runOperation,
|
||||
} from '@shumai/core/src/operations'
|
||||
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
@@ -357,23 +362,22 @@ describe('folder api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('GET /folders/:folderId/agentsmd', async () => {
|
||||
vi.spyOn(assetService, 'getAgentsMd').mockResolvedValue('# Folder Guidelines')
|
||||
it('GET /folders/:folderId/agentsmd runs get_folder_instructions', async () => {
|
||||
vi.mocked(runOperation).mockResolvedValue({
|
||||
folderId: 'test-id',
|
||||
content: '# Folder Guidelines',
|
||||
})
|
||||
|
||||
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
||||
const res = await app.request('/folders/test-id/agentsmd')
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const json = await res.json()
|
||||
expect(json.content).toBe('# Folder Guidelines')
|
||||
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||
user: { id: 'user1', name: 'Test User' },
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Asset,
|
||||
id: 'test-id',
|
||||
})
|
||||
expect(assetService.getAgentsMd).toHaveBeenCalledWith('test-id')
|
||||
expect(await res.json()).toEqual({ content: '# Folder Guidelines' })
|
||||
expect(runOperation).toHaveBeenCalledWith(
|
||||
getFolderInstructionsOp,
|
||||
{ userId: 'user1', via: 'api' },
|
||||
{ folderId: 'test-id' },
|
||||
)
|
||||
})
|
||||
|
||||
it('PATCH /folders/:folderId/agentsmd', async () => {
|
||||
|
||||
Reference in New Issue
Block a user