tallyfy 1.0.1__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tallyfy might be problematic. Click here for more details.

Files changed (93) hide show
  1. tallyfy-1.0.3/.cursor/rules/mcp-server-development.mdc +280 -0
  2. tallyfy-1.0.3/.github/workflows/deploy-host.yml +26 -0
  3. tallyfy-1.0.3/.github/workflows/deploy-server.yml +26 -0
  4. tallyfy-1.0.3/CLAUDE.md +551 -0
  5. {tallyfy-1.0.1/tallyfy.egg-info → tallyfy-1.0.3}/PKG-INFO +2 -2
  6. tallyfy-1.0.3/README.md +317 -0
  7. tallyfy-1.0.3/admin/__init__.py +7 -0
  8. tallyfy-1.0.3/admin/server.py +153 -0
  9. tallyfy-1.0.3/architecture.mmd +76 -0
  10. tallyfy-1.0.3/host/Dockerfile +12 -0
  11. tallyfy-1.0.3/host/client/.env +1 -0
  12. tallyfy-1.0.3/host/client/__init__.py +19 -0
  13. tallyfy-1.0.3/host/client/client.py +63 -0
  14. tallyfy-1.0.3/host/client/config.py +48 -0
  15. tallyfy-1.0.3/host/client/conversation.py +52 -0
  16. tallyfy-1.0.3/host/client/exceptions.py +21 -0
  17. tallyfy-1.0.3/host/client/mcp_client.py +211 -0
  18. tallyfy-1.0.3/host/client/prompts.py +84 -0
  19. tallyfy-1.0.3/host/docker-compose.yml +11 -0
  20. tallyfy-1.0.3/host/launcher.py +48 -0
  21. tallyfy-1.0.3/host/requirements.txt +11 -0
  22. tallyfy-1.0.3/host/websocket/__init__.py +1 -0
  23. tallyfy-1.0.3/host/websocket/server.py +368 -0
  24. tallyfy-1.0.3/host/websocket/session_manager.py +220 -0
  25. tallyfy-1.0.3/main.py +28 -0
  26. {tallyfy-1.0.1 → tallyfy-1.0.3}/pyproject.toml +1 -1
  27. {tallyfy-1.0.1 → tallyfy-1.0.3}/requirements.txt +1 -1
  28. tallyfy-1.0.3/server/.dockerignore +72 -0
  29. tallyfy-1.0.3/server/Dockerfile +12 -0
  30. tallyfy-1.0.3/server/__init__.py +0 -0
  31. tallyfy-1.0.3/server/docker-compose.yml +11 -0
  32. tallyfy-1.0.3/server/requirements.txt +4 -0
  33. tallyfy-1.0.3/server/server.py +116 -0
  34. tallyfy-1.0.3/server/tools/__init__.py +0 -0
  35. tallyfy-1.0.3/server/tools/automation.py +172 -0
  36. tallyfy-1.0.3/server/tools/date_utils.py +352 -0
  37. tallyfy-1.0.3/server/tools/form_fields.py +186 -0
  38. tallyfy-1.0.3/server/tools/process_management.py +58 -0
  39. tallyfy-1.0.3/server/tools/search.py +71 -0
  40. tallyfy-1.0.3/server/tools/task_management.py +342 -0
  41. tallyfy-1.0.3/server/tools/template_management.py +277 -0
  42. tallyfy-1.0.3/server/tools/user_management.py +125 -0
  43. {tallyfy-1.0.1 → tallyfy-1.0.3}/setup.py +1 -1
  44. tallyfy-1.0.3/start_servers.py +94 -0
  45. tallyfy-1.0.3/tallyfy/BUILD.md +5 -0
  46. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/README.md +1 -1
  47. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/core.py +5 -2
  48. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/models.py +63 -0
  49. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/template_management.py +28 -1
  50. tallyfy-1.0.3/tallyfy-requirements.txt +2 -0
  51. {tallyfy-1.0.1 → tallyfy-1.0.3/tallyfy.egg-info}/PKG-INFO +2 -2
  52. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy.egg-info/SOURCES.txt +43 -1
  53. tallyfy-1.0.3/ui/index.html +622 -0
  54. tallyfy-1.0.1/README.md +0 -199
  55. {tallyfy-1.0.1 → tallyfy-1.0.3}/CHANGELOG.md +0 -0
  56. {tallyfy-1.0.1 → tallyfy-1.0.3}/LICENSE +0 -0
  57. {tallyfy-1.0.1 → tallyfy-1.0.3}/MANIFEST.in +0 -0
  58. {tallyfy-1.0.1 → tallyfy-1.0.3}/setup.cfg +0 -0
  59. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/activity_feed.json +0 -0
  60. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/asset.json +0 -0
  61. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/authentication.json +0 -0
  62. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/favorites.json +0 -0
  63. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/file.json +0 -0
  64. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/folder.json +0 -0
  65. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/form_field.json +0 -0
  66. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/group.json +0 -0
  67. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/guest.json +0 -0
  68. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/list.json +0 -0
  69. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/member.json +0 -0
  70. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/organization.json +0 -0
  71. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/process.json +0 -0
  72. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/process_instances.json +0 -0
  73. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/public.json +0 -0
  74. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/public_process.json +0 -0
  75. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/public_template.json +0 -0
  76. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/recurringjob.json +0 -0
  77. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/search.json +0 -0
  78. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/security.json +0 -0
  79. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/selectedtextcomment.json +0 -0
  80. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/split_summary.json +0 -0
  81. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/step.json +0 -0
  82. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/tag.json +0 -0
  83. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/task.json +0 -0
  84. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/template.json +0 -0
  85. {tallyfy-1.0.1 → tallyfy-1.0.3}/swagger/watching.json +0 -0
  86. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/__init__.py +0 -0
  87. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/form_fields_management.py +0 -0
  88. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/task_management.py +0 -0
  89. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy/user_management.py +0 -0
  90. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy.egg-info/dependency_links.txt +0 -0
  91. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy.egg-info/not-zip-safe +0 -0
  92. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy.egg-info/requires.txt +0 -0
  93. {tallyfy-1.0.1 → tallyfy-1.0.3}/tallyfy.egg-info/top_level.txt +0 -0
@@ -0,0 +1,280 @@
1
+ # MCP Server Development Rules for Cursor
2
+
3
+ This file provides Cursor IDE with essential context for developing the MCP Server repository.
4
+
5
+ ## Project Context
6
+
7
+ This is a **Model Context Protocol (MCP) WebSocket Server** that enables multi-user access to Tallyfy workflow automation. The repository solves MCP's fundamental limitation of not supporting multi-user scenarios by implementing a session-based proxy layer.
8
+
9
+ ### Core Architecture
10
+ - **MCP Server** (`/server`): FastMCP 2.9.0-based server with 40+ tools
11
+ - **WebSocket Host** (`/host`): Multi-user session management
12
+ - **Tallyfy SDK** (`/tallyfy`): Workflow automation integration
13
+
14
+ ## Coding Standards
15
+
16
+ ### Python Style Guide
17
+ - **Formatting**: Use Black with 88-character line length
18
+ - **Type Hints**: Required for all functions (Python 3.7+ compatibility)
19
+ - **Docstrings**: NumPy style for all public functions
20
+ - **Imports**: Group by standard library, third-party, local imports
21
+
22
+ ### Tool Development Pattern
23
+ ```python
24
+ @mcp.tool()
25
+ async def tool_name(api_key: str, org_id: str, other_params...):
26
+ """
27
+ Tool description following NumPy convention.
28
+
29
+ Parameters
30
+ ----------
31
+ api_key : str
32
+ Tallyfy API key for authentication
33
+ org_id : str
34
+ Organization identifier
35
+
36
+ Returns
37
+ -------
38
+ dict
39
+ Tool operation result
40
+
41
+ Raises
42
+ ------
43
+ TallyfyError
44
+ When API operation fails
45
+ """
46
+ try:
47
+ with TallyfySDK(api_key=api_key) as sdk:
48
+ result = sdk.method(org_id, other_params)
49
+ return result
50
+ except TallyfyError as e:
51
+ logger.error(f"Tallyfy API error: {e}")
52
+ raise
53
+ ```
54
+
55
+ ### Session Management Patterns
56
+ ```python
57
+ # Always validate credentials before storing
58
+ def set_credentials(self, session_id: str, api_key: str, org_id: str) -> bool:
59
+ try:
60
+ sdk = TallyfySDK(api_key)
61
+ user_info = sdk.users.get_current_user_info(org_id)
62
+ if user_info:
63
+ # Store credentials only after verification
64
+ session.api_key = api_key
65
+ session.org_id = org_id
66
+ return True
67
+ except TallyfyError:
68
+ return False
69
+ finally:
70
+ if sdk:
71
+ sdk.close()
72
+ ```
73
+
74
+ ## Dependencies & Imports
75
+
76
+ ### Required Headers for Tallyfy API
77
+ ```python
78
+ headers = {
79
+ "Authorization": f"Bearer {api_key}",
80
+ "X-Tallyfy-Client": "APIClient", # MANDATORY
81
+ "Content-Type": "application/json"
82
+ }
83
+ ```
84
+
85
+ ### Core Dependencies
86
+ - `fastmcp==2.9.0`: MCP server framework
87
+ - `anthropic==0.52.2`: Claude API integration
88
+ - `websockets==11.0.3`: Real-time communication
89
+ - `tallyfy==1.0.3`: Workflow automation SDK
90
+ - `PyJWT>=2.8.0`: JWT token handling
91
+
92
+ ## Error Handling Requirements
93
+
94
+ ### Tallyfy API Errors
95
+ ```python
96
+ try:
97
+ # API operation
98
+ pass
99
+ except TallyfyError as e:
100
+ logger.error(f"Tallyfy API error: {e}")
101
+ raise TallyfyError(f"Operation failed: {e}")
102
+ except Exception as e:
103
+ logger.error(f"Unexpected error: {e}")
104
+ raise Exception(f"Unexpected error: {e}")
105
+ ```
106
+
107
+ ### WebSocket Error Handling
108
+ - Always gracefully handle connection cleanup
109
+ - Preserve session state on temporary disconnections
110
+ - Log errors with appropriate context
111
+ - Use structured error responses
112
+
113
+ ## Security Requirements
114
+
115
+ ### Critical Security Patterns
116
+ 1. **Credential Isolation**: Never share credentials between sessions
117
+ 2. **Input Validation**: Sanitize all user inputs before processing
118
+ 3. **Session Security**: Use UUID-based session IDs (not in URLs)
119
+ 4. **Memory-Only Storage**: No persistent credential storage
120
+
121
+ ### MCP Security Vulnerabilities to Avoid
122
+ - **Prompt Injection**: Validate all tool invocations with user approval
123
+ - **Tool Poisoning**: Monitor for changes in tool definitions
124
+ - **Command Injection**: Sanitize all inputs passed to system commands
125
+ - **Cross-Session Leakage**: Ensure session isolation
126
+
127
+ ## File Structure & Organization
128
+
129
+ ### Tool Categories
130
+ - `user_management.py`: Organization members, invitations, permissions
131
+ - `task_management.py`: Task operations, NLP date extraction
132
+ - `process_management.py`: Workflow instance management
133
+ - `template_management.py`: Blueprint operations, health analysis
134
+ - `form_fields.py`: Dynamic field creation and validation
135
+ - `search.py`: Universal search with filtering
136
+ - `automation.py`: Conditional rules and optimization
137
+
138
+ ### Key Configuration Files
139
+ - `server/requirements.txt`: MCP server dependencies
140
+ - `host/requirements.txt`: WebSocket server dependencies
141
+ - `pyproject.toml`: Package configuration and metadata
142
+ - `.github/workflows/`: Deployment automation
143
+
144
+ ## Development Workflow
145
+
146
+ ### Running the System
147
+ ```bash
148
+ # Start MCP server (port 9000)
149
+ python -m server.server
150
+
151
+ # Start WebSocket server (port 8765)
152
+ python run_websocket_server.py --debug
153
+ ```
154
+
155
+ ### Code Quality Checks
156
+ ```bash
157
+ # Format code
158
+ black . --line-length 88
159
+
160
+ # Type checking
161
+ mypy . --python-version 3.7
162
+
163
+ # Linting
164
+ flake8 .
165
+ ```
166
+
167
+ ### Environment Setup
168
+ ```bash
169
+ # Required environment variables
170
+ export ANTHROPIC_API_KEY="sk-ant-api03-..."
171
+ export TALLYFY_API_KEY="fallback-key"
172
+ export TALLYFY_ORG_ID="fallback-org"
173
+ ```
174
+
175
+ ## Common Patterns
176
+
177
+ ### Date Extraction
178
+ ```python
179
+ from tools.date_utils import DateExtractor
180
+
181
+ date_extractor = DateExtractor()
182
+ extracted_info = date_extractor.extract_task_info(user_text)
183
+ ```
184
+
185
+ ### User Resolution
186
+ ```python
187
+ def resolve_user_ids(org_id: str, api_key: str, user_names: List[str]) -> List[int]:
188
+ with TallyfySDK(api_key=api_key) as sdk:
189
+ users = sdk.get_organization_users_list(org_id)
190
+ # Resolution logic
191
+ return resolved_ids
192
+ ```
193
+
194
+ ### WebSocket Message Handling
195
+ ```python
196
+ async def handle_message(self, websocket: WebSocketServerProtocol, message: str):
197
+ try:
198
+ data = json.loads(message)
199
+ message_type = data.get("type", "query")
200
+
201
+ if message_type == "auth":
202
+ await self.handle_auth_message(websocket, session_id, data)
203
+ elif message_type == "query":
204
+ await self.handle_query_message(websocket, session_id, data.get("content"))
205
+ except Exception as e:
206
+ await self.send_error_response(websocket, str(e))
207
+ ```
208
+
209
+ ## Performance Considerations
210
+
211
+ ### Connection Management
212
+ - Implement heartbeat with 30s ping interval, 10s timeout
213
+ - Clean up inactive sessions every 5 minutes
214
+ - Use connection pooling for Tallyfy SDK instances
215
+
216
+ ### Memory Management
217
+ - Scope conversation history to sessions
218
+ - Implement periodic cleanup of abandoned sessions
219
+ - Use efficient JSON parsing and response caching
220
+
221
+ ## Testing Guidelines
222
+
223
+ ### Integration Testing
224
+ - Test WebSocket connection lifecycle
225
+ - Validate session management and isolation
226
+ - Verify Tallyfy API integration
227
+ - Test error handling scenarios
228
+
229
+ ### Manual Testing
230
+ ```bash
231
+ # Test WebSocket connection
232
+ # Open ui/index.html in browser
233
+ # Connect to ws://localhost:8765
234
+ # Authenticate with valid Tallyfy credentials
235
+ ```
236
+
237
+ ## Deployment Context
238
+
239
+ ### Production Environment
240
+ - **Target**: DigitalOcean droplet (143.198.69.152)
241
+ - **Ports**: 9000 (MCP), 8765 (WebSocket)
242
+ - **Transport**: HTTP-SSE and stdio support
243
+ - **Deployment**: GitHub Actions automated pipeline
244
+
245
+ ### Repository Relationships
246
+ This repository is part of Tallyfy's ecosystem:
247
+ - `api-v2/`: Laravel-based main API
248
+ - `client/`: Angular frontend application
249
+ - `documentation/`: User documentation
250
+ - `cloudflare-workers/`: Edge computing services
251
+
252
+ ## Common Issues & Solutions
253
+
254
+ ### Multi-User MCP Challenge
255
+ Problem: MCP doesn't support multi-user by default
256
+ Solution: Session-based proxy layer with credential isolation
257
+
258
+ ### Authentication Failures
259
+ - Verify `X-Tallyfy-Client` header is included
260
+ - Check API key validity with Tallyfy API
261
+ - Ensure org_id is accessible to the user
262
+
263
+ ### Session Management Issues
264
+ - Monitor session timeout (60 minutes)
265
+ - Check for proper credential cleanup
266
+ - Verify session ID uniqueness
267
+
268
+ ### WebSocket Connection Problems
269
+ - Check port availability (8765)
270
+ - Verify MCP server is running (port 9000)
271
+ - Monitor connection health with ping/pong
272
+
273
+ ## Documentation References
274
+
275
+ - FastMCP: https://gofastmcp.com/
276
+ - MCP Specification: https://modelcontextprotocol.io/
277
+ - Tallyfy API: https://go.tallyfy.com/api
278
+ - Repository Issues: 3 tracked issues in GitHub
279
+
280
+ Remember: This codebase implements a critical solution to MCP's multi-user limitation through sophisticated session management and security isolation.
@@ -0,0 +1,26 @@
1
+ name: Build & Deploy to instance
2
+
3
+
4
+ on:
5
+ push:
6
+ branches: [ "main" ]
7
+ paths:
8
+ - .github/workflows/deploy-host.yml
9
+ - host/**
10
+
11
+ jobs:
12
+ build-deploy-host:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - name: SSH config
17
+ uses: shimataro/ssh-key-action@v2.5.0
18
+ with:
19
+ key: ${{ secrets.SSH_PRIVATE_KEY }}
20
+ known_hosts: ${{ secrets.SSH_HOST }}
21
+ - name: Deploy
22
+ run: |
23
+ scp -v -rp host/* root@143.198.69.152:/home/mcp-host
24
+ - name: Build
25
+ run: |
26
+ ssh root@143.198.69.152 "cd /home/mcp-host && docker compose build && docker compose down && docker compose up -d"
@@ -0,0 +1,26 @@
1
+ name: Build & Deploy to instance
2
+
3
+
4
+ on:
5
+ push:
6
+ branches: [ "main" ]
7
+ paths:
8
+ - .github/workflows/deploy-server.yml
9
+ - server/**
10
+
11
+ jobs:
12
+ build-deploy-server:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - name: SSH config
17
+ uses: shimataro/ssh-key-action@v2.5.0
18
+ with:
19
+ key: ${{ secrets.SSH_PRIVATE_KEY }}
20
+ known_hosts: ${{ secrets.SSH_HOST }}
21
+ - name: Deploy
22
+ run: |
23
+ scp -v -rp server/* root@143.198.69.152:/home/mcp-server
24
+ - name: Build
25
+ run: |
26
+ ssh root@143.198.69.152 "cd /home/mcp-server && docker compose build && docker compose down && docker compose up -d"