Skip to content

refactor(knowledge): remove sandbox dependency for DingTalk document upload#3

Merged
parabala merged 1 commit intofeature/dingtalk-upload-knowledgefrom
wegent/remove-sandbox-from-knowledge-skill
Apr 27, 2026
Merged

refactor(knowledge): remove sandbox dependency for DingTalk document upload#3
parabala merged 1 commit intofeature/dingtalk-upload-knowledgefrom
wegent/remove-sandbox-from-knowledge-skill

Conversation

@parabala
Copy link
Copy Markdown
Owner

Summary

Remove sandbox exec dependency for DingTalk document upload by introducing dedicated MCP tools.

Changes

New MCP Tools (app/mcp_server/tools/dingtalk_upload.py)

  1. dingtalk_upload_file_from_url - Downloads file from URL and uploads to Wegent

    • Downloads file from DingTalk download_url
    • Uses secure temporary file handling
    • Automatically cleans up temp files after upload
    • Returns attachment_id for use with wegent_kb_create_document
  2. dingtalk_upload_content - Saves content to file and uploads to Wegent

    • Writes content (e.g., markdown) to temporary file
    • Supports configurable text encoding
    • Automatically cleans up temp files after upload
    • Returns attachment_id for use with wegent_kb_create_document

Updated Files

  • app/mcp_server/server.py: Import dingtalk_upload module for tool registration
  • app/mcp_server/tools/init.py: Export DINGTALK_UPLOAD_MCP_TOOLS
  • init_data/skills/wegent-knowledge/SKILL.md:
    • Remove all sandbox exec references
    • Document new helper tools
    • Update workflow steps and examples

Why

Previously, uploading DingTalk documents required using sandbox exec commands with curl, which:

  • Required shell access in the execution environment
  • Was error-prone with manual command construction
  • Made error handling difficult

The new approach:

  • Uses native Python HTTP requests
  • Provides proper error handling and logging
  • Handles temporary file cleanup automatically
  • Integrates seamlessly with existing attachment service

Test Plan

  • Test dingtalk_upload_file_from_url with file-based documents
  • Test dingtalk_upload_content with markdown content
  • Verify temporary files are cleaned up after upload
  • Verify attachment_id is returned correctly
  • Test error handling for invalid URLs
  • Test error handling for encoding issues

…upload

Add new MCP tools to replace sandbox exec for DingTalk document upload:

1. dingtalk_upload_file_from_url: Download file from URL and upload to Wegent
   - Downloads file from DingTalk download_url
   - Automatically manages temporary files
   - Returns attachment_id for wegent_kb_create_document

2. dingtalk_upload_content: Save content to file and upload to Wegent
   - Writes content to temporary file
   - Supports configurable encoding
   - Returns attachment_id for wegent_kb_create_document

Both tools:
- Use tempfile module for secure temporary file handling
- Clean up temporary files after upload (in finally block)
- Integrate with existing context_service.upload_attachment

Update SKILL.md:
- Remove all sandbox exec references
- Document new helper tools
- Update workflow and examples

Update server.py:
- Import dingtalk_upload module for tool registration

Fixes secret
@parabala parabala merged commit c56ecf4 into feature/dingtalk-upload-knowledge Apr 27, 2026
parabala added a commit that referenced this pull request Apr 27, 2026
…dge-skill

refactor(knowledge): remove sandbox dependency for DingTalk document upload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant