diff --git a/README.md b/README.md index 3c9eb670f..5fd5f6f0d 100644 --- a/README.md +++ b/README.md @@ -1,1077 +1,52 @@ -# GitHub MCP Server +# Rukn AlTasawoq - Backend Ops System -The GitHub MCP Server connects AI tools directly to GitHub's platform. This gives AI agents, assistants, and chatbots the ability to read repositories and code files, manage issues and PRs, analyze code, and automate workflows. All through natural language interactions. +This repository contains the backend system for the Rukn AlTasawoq project. It is a modular, AI-enhanced system designed to integrate customer journeys, affiliate systems, order automation, dynamic pricing, and personalized promotions. -### Use Cases +## Project Structure -- Repository Management: Browse and query code, search files, analyze commits, and understand project structure across any repository you have access to. -- Issue & PR Automation: Create, update, and manage issues and pull requests. Let AI help triage bugs, review code changes, and maintain project boards. -- CI/CD & Workflow Intelligence: Monitor GitHub Actions workflow runs, analyze build failures, manage releases, and get insights into your development pipeline. -- Code Analysis: Examine security findings, review Dependabot alerts, understand code patterns, and get comprehensive insights into your codebase. -- Team Collaboration: Access discussions, manage notifications, analyze team activity, and streamline processes for your team. +The project is organized into the following directories: -Built for developers who want to connect their AI tools to GitHub context and capabilities, from simple natural language queries to complex multi-step agent workflows. +- `rukn_altasawoq/`: The main Python package for the project. + - `models/`: Contains the Pydantic data models for the various entities in the system (e.g., `Client`, `Order`, `Quote`). + - `services/`: Contains modules for interacting with external services like Notion, Google Sheets, and ChatbotBuilder. + - `customer_engine/`: Logic for managing customer profiles and lifecycle. + - `affiliate_engine/`: Logic for the multi-level affiliate and commission system. + - `order_engine/`: Logic for handling quotes and orders. + - `offer_engine/`: Logic for the smart offer and promotion system. + - `shipping_engine/`: Logic for shipment tracking and logistics. + - `automation_engine/`: Logic for workflow automation. + - `analytics_engine/`: Logic for data analytics and reporting. + - `content_engine/`: Logic for content and campaign generation. + - `quote_engine/`: Contains the dynamic quote processor. +- `tests/`: Contains unit tests for the project. +- `requirements.txt`: A list of the Python dependencies for this project. ---- +## Getting Started -## Remote GitHub MCP Server - -[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D&quality=insiders) - -The remote GitHub MCP Server is hosted by GitHub and provides the easiest method for getting up and running. If your MCP host does not support remote MCP servers, don't worry! You can use the [local version of the GitHub MCP Server](https://github.com/github/github-mcp-server?tab=readme-ov-file#local-github-mcp-server) instead. - -### Prerequisites - -1. A compatible MCP host with remote server support (VS Code 1.101+, Claude Desktop, Cursor, Windsurf, etc.) -2. Any applicable [policies enabled](https://github.com/github/github-mcp-server/blob/main/docs/policies-and-governance.md) - -### Install in VS Code - -For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start. Make sure you're using [VS Code 1.101](https://code.visualstudio.com/updates/v1_101) or [later](https://code.visualstudio.com/updates) for remote MCP and OAuth support. - -Alternatively, to manually configure VS Code, choose the appropriate JSON block from the examples below and add it to your host configuration: - - - - - - - - -
Using OAuthUsing a GitHub PAT
VS Code (version 1.101 or greater)
- -```json -{ - "servers": { - "github": { - "type": "http", - "url": "https://api.githubcopilot.com/mcp/" - } - } -} -``` - - - -```json -{ - "servers": { - "github": { - "type": "http", - "url": "https://api.githubcopilot.com/mcp/", - "headers": { - "Authorization": "Bearer ${input:github_mcp_pat}" - } - } - }, - "inputs": [ - { - "type": "promptString", - "id": "github_mcp_pat", - "description": "GitHub Personal Access Token", - "password": true - } - ] -} -``` - -
- -### Install in other MCP hosts -- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot -- **[Claude Applications](/docs/installation-guides/install-claude.md)** - Installation guide for Claude Web, Claude Desktop and Claude Code CLI -- **[Cursor](/docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE -- **[Windsurf](/docs/installation-guides/install-windsurf.md)** - Installation guide for Windsurf IDE - -> **Note:** Each MCP host application needs to configure a GitHub App or OAuth App to support remote access via OAuth. Any host application that supports remote MCP servers should support the remote GitHub server with PAT authentication. Configuration details and support levels vary by host. Make sure to refer to the host application's documentation for more info. - -> ⚠️ **Public Preview Status:** The **remote** GitHub MCP Server is currently in Public Preview. During preview, access may be gated depending on authentication type and surface: -> - OAuth: Subject to GitHub Copilot Editor Preview Policy until GA -> - PAT: Controlled via your organization's PAT policies -> - MCP Servers in Copilot policy: Enables/disables access to all MCP servers in VS Code, with other Copilot editors migrating to this policy in the coming months. - -### Configuration -See [Remote Server Documentation](/docs/remote-server.md) on how to pass additional configuration settings to the remote GitHub MCP Server. - ---- - -## Local GitHub MCP Server - -[![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=github&inputs=%5B%7B%22id%22%3A%22github_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22GitHub%20Personal%20Access%20Token%22%2C%22password%22%3Atrue%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22GITHUB_PERSONAL_ACCESS_TOKEN%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_PERSONAL_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agithub_token%7D%22%7D%7D) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=github&inputs=%5B%7B%22id%22%3A%22github_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22GitHub%20Personal%20Access%20Token%22%2C%22password%22%3Atrue%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22GITHUB_PERSONAL_ACCESS_TOKEN%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_PERSONAL_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agithub_token%7D%22%7D%7D&quality=insiders) - -### Prerequisites - -1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed. -2. Once Docker is installed, you will also need to ensure Docker is running. The image is public; if you get errors on pull, you may have an expired token and need to `docker logout ghcr.io`. -3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new). -The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)). - -
Handling PATs Securely - -### Environment Variables (Recommended) -To keep your GitHub PAT secure and reusable across different MCP hosts: - -1. **Store your PAT in environment variables** +1. **Clone the repository:** ```bash - export GITHUB_PAT=your_token_here - ``` - Or create a `.env` file: - ```env - GITHUB_PAT=your_token_here + git clone ``` -2. **Protect your `.env` file** +2. **Install the dependencies:** ```bash - # Add to .gitignore to prevent accidental commits - echo ".env" >> .gitignore + pip install -r requirements.txt ``` -3. **Reference the token in configurations** - ```bash - # CLI usage - claude mcp update github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT - - # In config files (where supported) - "env": { - "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT" - } - ``` - -> **Note**: Environment variable support varies by host app and IDE. Some applications (like Windsurf) require hardcoded tokens in config files. - -### Token Security Best Practices - -- **Minimum scopes**: Only grant necessary permissions - - `repo` - Repository operations - - `read:packages` - Docker image access -- **Separate tokens**: Use different PATs for different projects/environments -- **Regular rotation**: Update tokens periodically -- **Never commit**: Keep tokens out of version control -- **File permissions**: Restrict access to config files containing tokens - ```bash - chmod 600 ~/.your-app/config.json - ``` - -
- -## Installation - -### Install in GitHub Copilot on VS Code - -For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start. - -More about using MCP server tools in VS Code's [agent mode documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers). - -Install in GitHub Copilot on other IDEs (JetBrains, Visual Studio, Eclipse, etc.) - -Add the following JSON block to your IDE's MCP settings. - -```json -{ - "mcp": { - "inputs": [ - { - "type": "promptString", - "id": "github_token", - "description": "GitHub Personal Access Token", - "password": true - } - ], - "servers": { - "github": { - "command": "docker", - "args": [ - "run", - "-i", - "--rm", - "-e", - "GITHUB_PERSONAL_ACCESS_TOKEN", - "ghcr.io/github/github-mcp-server" - ], - "env": { - "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" - } - } - } - } -} -``` - -Optionally, you can add a similar example (i.e. without the mcp key) to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with other host applications that accept the same format. - -
-Example JSON block without the MCP key included -
- -```json -{ - "inputs": [ - { - "type": "promptString", - "id": "github_token", - "description": "GitHub Personal Access Token", - "password": true - } - ], - "servers": { - "github": { - "command": "docker", - "args": [ - "run", - "-i", - "--rm", - "-e", - "GITHUB_PERSONAL_ACCESS_TOKEN", - "ghcr.io/github/github-mcp-server" - ], - "env": { - "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" - } - } - } -} -``` - -
- -### Install in Other MCP Hosts - -For other MCP host applications, please refer to our installation guides: - -- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot -- **[Claude Code & Claude Desktop](docs/installation-guides/install-claude.md)** - Installation guide for Claude Code and Claude Desktop -- **[Cursor](docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE -- **[Windsurf](docs/installation-guides/install-windsurf.md)** - Installation guide for Windsurf IDE - -For a complete overview of all installation options, see our **[Installation Guides Index](docs/installation-guides/installation-guides.md)**. - -> **Note:** Any host application that supports local MCP servers should be able to access the local GitHub MCP server. However, the specific configuration process, syntax and stability of the integration will vary by host application. While many may follow a similar format to the examples above, this is not guaranteed. Please refer to your host application's documentation for the correct MCP configuration syntax and setup process. - -### Build from source - -If you don't have Docker, you can use `go build` to build the binary in the -`cmd/github-mcp-server` directory, and use the `github-mcp-server stdio` command with the `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable set to your token. To specify the output location of the build, use the `-o` flag. You should configure your server to use the built executable as its `command`. For example: - -```JSON -{ - "mcp": { - "servers": { - "github": { - "command": "/path/to/github-mcp-server", - "args": ["stdio"], - "env": { - "GITHUB_PERSONAL_ACCESS_TOKEN": "" - } - } - } - } -} -``` - -## Tool Configuration - -The GitHub MCP Server supports enabling or disabling specific groups of functionalities via the `--toolsets` flag. This allows you to control which GitHub API capabilities are available to your AI tools. Enabling only the toolsets that you need can help the LLM with tool choice and reduce the context size. - -_Toolsets are not limited to Tools. Relevant MCP Resources and Prompts are also included where applicable._ - -### Available Toolsets - -The following sets of tools are available (all are on by default): - - -| Toolset | Description | -| ----------------------- | ------------------------------------------------------------- | -| `context` | **Strongly recommended**: Tools that provide context about the current user and GitHub context you are operating in | -| `actions` | GitHub Actions workflows and CI/CD operations | -| `code_security` | Code security related tools, such as GitHub Code Scanning | -| `dependabot` | Dependabot tools | -| `discussions` | GitHub Discussions related tools | -| `experiments` | Experimental features that are not considered stable yet | -| `gists` | GitHub Gist related tools | -| `issues` | GitHub Issues related tools | -| `notifications` | GitHub Notifications related tools | -| `orgs` | GitHub Organization related tools | -| `pull_requests` | GitHub Pull Request related tools | -| `repos` | GitHub Repository related tools | -| `secret_protection` | Secret protection related tools, such as GitHub Secret Scanning | -| `users` | GitHub User related tools | - - -## Tools - - - -
- -Actions - -- **cancel_workflow_run** - Cancel workflow run - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **delete_workflow_run_logs** - Delete workflow logs - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **download_workflow_run_artifact** - Download workflow artifact - - `artifact_id`: The unique identifier of the artifact (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **get_job_logs** - Get job logs - - `failed_only`: When true, gets logs for all failed jobs in run_id (boolean, optional) - - `job_id`: The unique identifier of the workflow job (required for single job logs) (number, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `return_content`: Returns actual log content instead of URLs (boolean, optional) - - `run_id`: Workflow run ID (required when using failed_only) (number, optional) - - `tail_lines`: Number of lines to return from the end of the log (number, optional) - -- **get_workflow_run** - Get workflow run - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **get_workflow_run_logs** - Get workflow run logs - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **get_workflow_run_usage** - Get workflow usage - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **list_workflow_jobs** - List workflow jobs - - `filter`: Filters jobs by their completed_at timestamp (string, optional) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **list_workflow_run_artifacts** - List workflow artifacts - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **list_workflow_runs** - List workflow runs - - `actor`: Returns someone's workflow runs. Use the login for the user who created the workflow run. (string, optional) - - `branch`: Returns workflow runs associated with a branch. Use the name of the branch. (string, optional) - - `event`: Returns workflow runs for a specific event type (string, optional) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `status`: Returns workflow runs with the check run status (string, optional) - - `workflow_id`: The workflow ID or workflow file name (string, required) - -- **list_workflows** - List workflows - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - -- **rerun_failed_jobs** - Rerun failed jobs - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **rerun_workflow_run** - Rerun workflow run - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `run_id`: The unique identifier of the workflow run (number, required) - -- **run_workflow** - Run workflow - - `inputs`: Inputs the workflow accepts (object, optional) - - `owner`: Repository owner (string, required) - - `ref`: The git reference for the workflow. The reference can be a branch or tag name. (string, required) - - `repo`: Repository name (string, required) - - `workflow_id`: The workflow ID (numeric) or workflow file name (e.g., main.yml, ci.yaml) (string, required) - -
- -
- -Code Security - -- **get_code_scanning_alert** - Get code scanning alert - - `alertNumber`: The number of the alert. (number, required) - - `owner`: The owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - -- **list_code_scanning_alerts** - List code scanning alerts - - `owner`: The owner of the repository. (string, required) - - `ref`: The Git reference for the results you want to list. (string, optional) - - `repo`: The name of the repository. (string, required) - - `severity`: Filter code scanning alerts by severity (string, optional) - - `state`: Filter code scanning alerts by state. Defaults to open (string, optional) - - `tool_name`: The name of the tool used for code scanning. (string, optional) - -
- -
- -Context - -- **get_me** - Get my user profile - - No parameters required - -
- -
- -Dependabot - -- **get_dependabot_alert** - Get dependabot alert - - `alertNumber`: The number of the alert. (number, required) - - `owner`: The owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - -- **list_dependabot_alerts** - List dependabot alerts - - `owner`: The owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - - `severity`: Filter dependabot alerts by severity (string, optional) - - `state`: Filter dependabot alerts by state. Defaults to open (string, optional) - -
- -
- -Discussions - -- **get_discussion** - Get discussion - - `discussionNumber`: Discussion Number (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **get_discussion_comments** - Get discussion comments - - `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional) - - `discussionNumber`: Discussion Number (number, required) - - `owner`: Repository owner (string, required) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - -- **list_discussion_categories** - List discussion categories - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **list_discussions** - List discussions - - `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional) - - `category`: Optional filter by discussion category ID. If provided, only discussions with this category are listed. (string, optional) - - `direction`: Order direction. (string, optional) - - `orderBy`: Order discussions by field. If provided, the 'direction' also needs to be provided. (string, optional) - - `owner`: Repository owner (string, required) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name. If not provided, discussions will be queried at the organisation level. (string, optional) - -
- -
- -Gists - -- **create_gist** - Create Gist - - `content`: Content for simple single-file gist creation (string, required) - - `description`: Description of the gist (string, optional) - - `filename`: Filename for simple single-file gist creation (string, required) - - `public`: Whether the gist is public (boolean, optional) - -- **list_gists** - List Gists - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `since`: Only gists updated after this time (ISO 8601 timestamp) (string, optional) - - `username`: GitHub username (omit for authenticated user's gists) (string, optional) - -- **update_gist** - Update Gist - - `content`: Content for the file (string, required) - - `description`: Updated description of the gist (string, optional) - - `filename`: Filename to update or create (string, required) - - `gist_id`: ID of the gist to update (string, required) - -
- -
- -Issues - -- **add_issue_comment** - Add comment to issue - - `body`: Comment content (string, required) - - `issue_number`: Issue number to comment on (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **add_sub_issue** - Add sub-issue - - `issue_number`: The number of the parent issue (number, required) - - `owner`: Repository owner (string, required) - - `replace_parent`: When true, replaces the sub-issue's current parent issue (boolean, optional) - - `repo`: Repository name (string, required) - - `sub_issue_id`: The ID of the sub-issue to add. ID is not the same as issue number (number, required) - -- **assign_copilot_to_issue** - Assign Copilot to issue - - `issueNumber`: Issue number (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **create_issue** - Open new issue - - `assignees`: Usernames to assign to this issue (string[], optional) - - `body`: Issue body content (string, optional) - - `labels`: Labels to apply to this issue (string[], optional) - - `milestone`: Milestone number (number, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `title`: Issue title (string, required) - -- **get_issue** - Get issue details - - `issue_number`: The number of the issue (number, required) - - `owner`: The owner of the repository (string, required) - - `repo`: The name of the repository (string, required) - -- **get_issue_comments** - Get issue comments - - `issue_number`: Issue number (number, required) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - -- **list_issues** - List issues - - `direction`: Sort direction (string, optional) - - `labels`: Filter by labels (string[], optional) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `since`: Filter by date (ISO 8601 timestamp) (string, optional) - - `sort`: Sort order (string, optional) - - `state`: Filter by state (string, optional) - -- **list_sub_issues** - List sub-issues - - `issue_number`: Issue number (number, required) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (default: 1) (number, optional) - - `per_page`: Number of results per page (max 100, default: 30) (number, optional) - - `repo`: Repository name (string, required) - -- **remove_sub_issue** - Remove sub-issue - - `issue_number`: The number of the parent issue (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `sub_issue_id`: The ID of the sub-issue to remove. ID is not the same as issue number (number, required) - -- **reprioritize_sub_issue** - Reprioritize sub-issue - - `after_id`: The ID of the sub-issue to be prioritized after (either after_id OR before_id should be specified) (number, optional) - - `before_id`: The ID of the sub-issue to be prioritized before (either after_id OR before_id should be specified) (number, optional) - - `issue_number`: The number of the parent issue (number, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `sub_issue_id`: The ID of the sub-issue to reprioritize. ID is not the same as issue number (number, required) - -- **search_issues** - Search issues - - `order`: Sort order (string, optional) - - `owner`: Optional repository owner. If provided with repo, only notifications for this repository are listed. (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: Search query using GitHub issues search syntax (string, required) - - `repo`: Optional repository name. If provided with owner, only notifications for this repository are listed. (string, optional) - - `sort`: Sort field by number of matches of categories, defaults to best match (string, optional) - -- **update_issue** - Edit issue - - `assignees`: New assignees (string[], optional) - - `body`: New description (string, optional) - - `issue_number`: Issue number to update (number, required) - - `labels`: New labels (string[], optional) - - `milestone`: New milestone number (number, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `state`: New state (string, optional) - - `title`: New title (string, optional) - -
- -
- -Notifications - -- **dismiss_notification** - Dismiss notification - - `state`: The new state of the notification (read/done) (string, optional) - - `threadID`: The ID of the notification thread (string, required) - -- **get_notification_details** - Get notification details - - `notificationID`: The ID of the notification (string, required) - -- **list_notifications** - List notifications - - `before`: Only show notifications updated before the given time (ISO 8601 format) (string, optional) - - `filter`: Filter notifications to, use default unless specified. Read notifications are ones that have already been acknowledged by the user. Participating notifications are those that the user is directly involved in, such as issues or pull requests they have commented on or created. (string, optional) - - `owner`: Optional repository owner. If provided with repo, only notifications for this repository are listed. (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Optional repository name. If provided with owner, only notifications for this repository are listed. (string, optional) - - `since`: Only show notifications updated after the given time (ISO 8601 format) (string, optional) - -- **manage_notification_subscription** - Manage notification subscription - - `action`: Action to perform: ignore, watch, or delete the notification subscription. (string, required) - - `notificationID`: The ID of the notification thread. (string, required) - -- **manage_repository_notification_subscription** - Manage repository notification subscription - - `action`: Action to perform: ignore, watch, or delete the repository notification subscription. (string, required) - - `owner`: The account owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - -- **mark_all_notifications_read** - Mark all notifications as read - - `lastReadAt`: Describes the last point that notifications were checked (optional). Default: Now (string, optional) - - `owner`: Optional repository owner. If provided with repo, only notifications for this repository are marked as read. (string, optional) - - `repo`: Optional repository name. If provided with owner, only notifications for this repository are marked as read. (string, optional) - -
- -
- -Organizations - -- **search_orgs** - Search organizations - - `order`: Sort order (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: Organization search query. Examples: 'microsoft', 'location:california', 'created:>=2025-01-01'. Search is automatically scoped to type:org. (string, required) - - `sort`: Sort field by category (string, optional) - -
- -
- -Pull Requests - -- **add_comment_to_pending_review** - Add review comment to the requester's latest pending pull request review - - `body`: The text of the review comment (string, required) - - `line`: The line of the blob in the pull request diff that the comment applies to. For multi-line comments, the last line of the range (number, optional) - - `owner`: Repository owner (string, required) - - `path`: The relative path to the file that necessitates a comment (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - - `side`: The side of the diff to comment on. LEFT indicates the previous state, RIGHT indicates the new state (string, optional) - - `startLine`: For multi-line comments, the first line of the range that the comment applies to (number, optional) - - `startSide`: For multi-line comments, the starting side of the diff that the comment applies to. LEFT indicates the previous state, RIGHT indicates the new state (string, optional) - - `subjectType`: The level at which the comment is targeted (string, required) - -- **create_and_submit_pull_request_review** - Create and submit a pull request review without comments - - `body`: Review comment text (string, required) - - `commitID`: SHA of commit to review (string, optional) - - `event`: Review action to perform (string, required) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **create_pending_pull_request_review** - Create pending pull request review - - `commitID`: SHA of commit to review (string, optional) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **create_pull_request** - Open new pull request - - `base`: Branch to merge into (string, required) - - `body`: PR description (string, optional) - - `draft`: Create as draft PR (boolean, optional) - - `head`: Branch containing changes (string, required) - - `maintainer_can_modify`: Allow maintainer edits (boolean, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `title`: PR title (string, required) - -- **delete_pending_pull_request_review** - Delete the requester's latest pending pull request review - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request** - Get pull request details - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request_comments** - Get pull request comments - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request_diff** - Get pull request diff - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request_files** - Get pull request files - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request_reviews** - Get pull request reviews - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **get_pull_request_status** - Get pull request status checks - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **list_pull_requests** - List pull requests - - `base`: Filter by base branch (string, optional) - - `direction`: Sort direction (string, optional) - - `head`: Filter by head user/org and branch (string, optional) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `sort`: Sort by (string, optional) - - `state`: Filter by state (string, optional) - -- **merge_pull_request** - Merge pull request - - `commit_message`: Extra detail for merge commit (string, optional) - - `commit_title`: Title for merge commit (string, optional) - - `merge_method`: Merge method (string, optional) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **request_copilot_review** - Request Copilot review - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **search_pull_requests** - Search pull requests - - `order`: Sort order (string, optional) - - `owner`: Optional repository owner. If provided with repo, only notifications for this repository are listed. (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: Search query using GitHub pull request search syntax (string, required) - - `repo`: Optional repository name. If provided with owner, only notifications for this repository are listed. (string, optional) - - `sort`: Sort field by number of matches of categories, defaults to best match (string, optional) - -- **submit_pending_pull_request_review** - Submit the requester's latest pending pull request review - - `body`: The text of the review comment (string, optional) - - `event`: The event to perform (string, required) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -- **update_pull_request** - Edit pull request - - `base`: New base branch name (string, optional) - - `body`: New description (string, optional) - - `draft`: Mark pull request as draft (true) or ready for review (false) (boolean, optional) - - `maintainer_can_modify`: Allow maintainer edits (boolean, optional) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number to update (number, required) - - `repo`: Repository name (string, required) - - `state`: New state (string, optional) - - `title`: New title (string, optional) - -- **update_pull_request_branch** - Update pull request branch - - `expectedHeadSha`: The expected SHA of the pull request's HEAD ref (string, optional) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - -
- -
- -Repositories - -- **create_branch** - Create branch - - `branch`: Name for new branch (string, required) - - `from_branch`: Source branch (defaults to repo default) (string, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **create_or_update_file** - Create or update file - - `branch`: Branch to create/update the file in (string, required) - - `content`: Content of the file (string, required) - - `message`: Commit message (string, required) - - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path where to create/update the file (string, required) - - `repo`: Repository name (string, required) - - `sha`: Required if updating an existing file. The blob SHA of the file being replaced. (string, optional) - -- **create_repository** - Create repository - - `autoInit`: Initialize with README (boolean, optional) - - `description`: Repository description (string, optional) - - `name`: Repository name (string, required) - - `private`: Whether repo should be private (boolean, optional) - -- **delete_file** - Delete file - - `branch`: Branch to delete the file from (string, required) - - `message`: Commit message (string, required) - - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path to the file to delete (string, required) - - `repo`: Repository name (string, required) - -- **fork_repository** - Fork repository - - `organization`: Organization to fork to (string, optional) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **get_commit** - Get commit details - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `sha`: Commit SHA, branch name, or tag name (string, required) - -- **get_file_contents** - Get file or directory contents - - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path to file/directory (directories must end with a slash '/') (string, optional) - - `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional) - - `repo`: Repository name (string, required) - - `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional) - -- **get_tag** - Get tag details - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - - `tag`: Tag name (string, required) - -- **list_branches** - List branches - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - -- **list_commits** - List commits - - `author`: Author username or email address to filter commits by (string, optional) - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - - `sha`: Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository. If a commit SHA is provided, will list commits up to that SHA. (string, optional) - -- **list_tags** - List tags - - `owner`: Repository owner (string, required) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `repo`: Repository name (string, required) - -- **push_files** - Push files to repository - - `branch`: Branch to push to (string, required) - - `files`: Array of file objects to push, each object with path (string) and content (string) (object[], required) - - `message`: Commit message (string, required) - - `owner`: Repository owner (string, required) - - `repo`: Repository name (string, required) - -- **search_code** - Search code - - `order`: Sort order for results (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: Search query using GitHub's powerful code search syntax. Examples: 'content:Skill language:Java org:github', 'NOT is:archived language:Python OR language:go', 'repo:github/github-mcp-server'. Supports exact matching, language filters, path filters, and more. (string, required) - - `sort`: Sort field ('indexed' only) (string, optional) - -- **search_repositories** - Search repositories - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: Repository search query. Examples: 'machine learning in:name stars:>1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering. (string, required) - -
- -
- -Secret Protection - -- **get_secret_scanning_alert** - Get secret scanning alert - - `alertNumber`: The number of the alert. (number, required) - - `owner`: The owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - -- **list_secret_scanning_alerts** - List secret scanning alerts - - `owner`: The owner of the repository. (string, required) - - `repo`: The name of the repository. (string, required) - - `resolution`: Filter by resolution (string, optional) - - `secret_type`: A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter. (string, optional) - - `state`: Filter by state (string, optional) - -
- -
- -Users - -- **search_users** - Search users - - `order`: Sort order (string, optional) - - `page`: Page number for pagination (min 1) (number, optional) - - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - - `query`: User search query. Examples: 'john smith', 'location:seattle', 'followers:>100'. Search is automatically scoped to type:user. (string, required) - - `sort`: Sort users by number of followers or repositories, or when the person joined GitHub. (string, optional) - -
- - -### Additional Tools in Remote Github MCP Server - -
- -Copilot coding agent - -- **create_pull_request_with_copilot** - Perform task with GitHub Copilot coding agent - - `owner`: Repository owner. You can guess the owner, but confirm it with the user before proceeding. (string, required) - - `repo`: Repository name. You can guess the repository name, but confirm it with the user before proceeding. (string, required) - - `problem_statement`: Detailed description of the task to be performed (e.g., 'Implement a feature that does X', 'Fix bug Y', etc.) (string, required) - - `title`: Title for the pull request that will be created (string, required) - - `base_ref`: Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch (string, optional) - -
- -#### Specifying Toolsets - -To specify toolsets you want available to the LLM, you can pass an allow-list in two ways: - -1. **Using Command Line Argument**: +3. **Set up environment variables:** + - Create a `.env` file in the root of the project. + - Add the following environment variables to the `.env` file: + ``` + NOTION_API_KEY=your_notion_api_key + GOOGLE_SHEETS_CREDENTIALS_PATH=/path/to/your/google-sheets-credentials.json + CHATBOT_BUILDER_API_KEY=your_chatbot_builder_api_key + ``` +4. **Run the tests:** ```bash - github-mcp-server --toolsets repos,issues,pull_requests,actions,code_security + python -m unittest discover -s rukn_altasawoq/tests ``` -2. **Using Environment Variable**: - ```bash - GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" ./github-mcp-server - ``` - -The environment variable `GITHUB_TOOLSETS` takes precedence over the command line argument if both are provided. - -### Using Toolsets With Docker - -When using Docker, you can pass the toolsets as environment variables: - -```bash -docker run -i --rm \ - -e GITHUB_PERSONAL_ACCESS_TOKEN= \ - -e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security,experiments" \ - ghcr.io/github/github-mcp-server -``` - -### The "all" Toolset - -The special toolset `all` can be provided to enable all available toolsets regardless of any other configuration: - -```bash -./github-mcp-server --toolsets all -``` - -Or using the environment variable: - -```bash -GITHUB_TOOLSETS="all" ./github-mcp-server -``` - -## Dynamic Tool Discovery - -**Note**: This feature is currently in beta and may not be available in all environments. Please test it out and let us know if you encounter any issues. - -Instead of starting with all tools enabled, you can turn on dynamic toolset discovery. Dynamic toolsets allow the MCP host to list and enable toolsets in response to a user prompt. This should help to avoid situations where the model gets confused by the sheer number of tools available. - -### Using Dynamic Tool Discovery - -When using the binary, you can pass the `--dynamic-toolsets` flag. - -```bash -./github-mcp-server --dynamic-toolsets -``` - -When using Docker, you can pass the toolsets as environment variables: - -```bash -docker run -i --rm \ - -e GITHUB_PERSONAL_ACCESS_TOKEN= \ - -e GITHUB_DYNAMIC_TOOLSETS=1 \ - ghcr.io/github/github-mcp-server -``` - -## Read-Only Mode - -To run the server in read-only mode, you can use the `--read-only` flag. This will only offer read-only tools, preventing any modifications to repositories, issues, pull requests, etc. - -```bash -./github-mcp-server --read-only -``` - -When using Docker, you can pass the read-only mode as an environment variable: - -```bash -docker run -i --rm \ - -e GITHUB_PERSONAL_ACCESS_TOKEN= \ - -e GITHUB_READ_ONLY=1 \ - ghcr.io/github/github-mcp-server -``` - -## GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com) - -The flag `--gh-host` and the environment variable `GITHUB_HOST` can be used to set -the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data residency. - -- For GitHub Enterprise Server, prefix the hostname with the `https://` URI scheme, as it otherwise defaults to `http://`, which GitHub Enterprise Server does not support. -- For GitHub Enterprise Cloud with data residency, use `https://YOURSUBDOMAIN.ghe.com` as the hostname. -``` json -"github": { - "command": "docker", - "args": [ - "run", - "-i", - "--rm", - "-e", - "GITHUB_PERSONAL_ACCESS_TOKEN", - "-e", - "GITHUB_HOST", - "ghcr.io/github/github-mcp-server" - ], - "env": { - "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}", - "GITHUB_HOST": "https://" - } -} -``` - -## i18n / Overriding Descriptions - -The descriptions of the tools can be overridden by creating a -`github-mcp-server-config.json` file in the same directory as the binary. - -The file should contain a JSON object with the tool names as keys and the new -descriptions as values. For example: - -```json -{ - "TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "an alternative description", - "TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository" -} -``` - -You can create an export of the current translations by running the binary with -the `--export-translations` flag. - -This flag will preserve any translations/overrides you have made, while adding -any new translations that have been added to the binary since the last time you -exported. - -```sh -./github-mcp-server --export-translations -cat github-mcp-server-config.json -``` - -You can also use ENV vars to override the descriptions. The environment -variable names are the same as the keys in the JSON file, prefixed with -`GITHUB_MCP_` and all uppercase. - -For example, to override the `TOOL_ADD_ISSUE_COMMENT_DESCRIPTION` tool, you can -set the following environment variable: - -```sh -export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description" -``` - -## Library Usage - -The exported Go API of this module should currently be considered unstable, and subject to breaking changes. In the future, we may offer stability; please file an issue if there is a use case where this would be valuable. - -## License +## Contributing -This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms. \ No newline at end of file +Please follow the existing coding style and add unit tests for any new features or bug fixes. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..6157f3ba1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +requests +beautifulsoup4 +pydantic +notion-client +gspread +oauth2client diff --git a/rukn_altasawoq/models/__pycache__/schemas.cpython-312.pyc b/rukn_altasawoq/models/__pycache__/schemas.cpython-312.pyc new file mode 100644 index 000000000..968fcdfb0 Binary files /dev/null and b/rukn_altasawoq/models/__pycache__/schemas.cpython-312.pyc differ diff --git a/rukn_altasawoq/models/schemas.py b/rukn_altasawoq/models/schemas.py new file mode 100644 index 000000000..f1779e193 --- /dev/null +++ b/rukn_altasawoq/models/schemas.py @@ -0,0 +1,121 @@ +from pydantic import BaseModel, Field +from typing import List, Optional +from datetime import datetime + +from uuid import uuid4 + +class Client(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + name: str + phone: str + sessions: List[str] = [] + addresses: List[str] = [] + wallet_id: Optional[str] = None + affiliate_level: str = "Free" + loyalty_points: int = 0 + preferences: dict = {} + behavior_history: List[str] = [] + customer_type: str = "New" + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Quote(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + customer_id: str + product_links: List[str] = [] + images: List[str] = [] + cart: List[dict] = [] + voice_note: Optional[str] = None + quote_price: float + markup_percentage: float = 35.0 + tax: float = 0.0 + discount: float = 0.0 + final_price: float + urgency_tag: Optional[str] = None + status: str = "Pending" # Pending, Approved, Rejected + handler_id: Optional[str] = None + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Order(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + quote_id: str + customer_id: str + products: List[dict] + total_price: float + payment_status: str = "Unpaid" # Unpaid, Paid, Refunded + order_status: str = "Confirmed" # Confirmed, Shipped, Delivered, Canceled + shipping_id: Optional[str] = None + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Wallet(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + customer_id: str + balance: float = 0.0 + transactions: List[dict] = [] + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Coupon(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + code: str + discount_percentage: Optional[float] = None + discount_amount: Optional[float] = None + valid_from: datetime + valid_to: datetime + is_active: bool = True + usage_limit: int = 1 + used_count: int = 0 + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Product(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + name: str + description: Optional[str] = None + price: float + currency: str = "USD" + supplier: Optional[str] = None + product_url: Optional[str] = None + images: List[str] = [] + attributes: dict = {} + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Shipment(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + order_id: str + tracking_number: str + provider: str + status: str = "Pending" # Pending, In-Transit, Delivered, Failed + tracking_history: List[dict] = [] + media: dict = { + "invoice": Optional[str], + "proof_of_delivery": Optional[str], + "waybill": Optional[str], + "warehouse_receipt": Optional[str], + } + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) + + +class Affiliate(BaseModel): + id: str = Field(default_factory=lambda: str(uuid4()), alias="_id") + client_id: str + level: str # Free, Paid, Sponsored + upline_id: Optional[str] = None + downline_ids: List[str] = [] + commission_rate: float + commission_balance: float = 0.0 + performance_score: float = 0.0 + linked_offers: List[str] = [] + traffic_sources: List[str] = [] + created_at: datetime = Field(default_factory=datetime.utcnow) + updated_at: datetime = Field(default_factory=datetime.utcnow) diff --git a/rukn_altasawoq/quote_engine/__pycache__/processor.cpython-312.pyc b/rukn_altasawoq/quote_engine/__pycache__/processor.cpython-312.pyc new file mode 100644 index 000000000..296ac82d9 Binary files /dev/null and b/rukn_altasawoq/quote_engine/__pycache__/processor.cpython-312.pyc differ diff --git a/rukn_altasawoq/quote_engine/processor.py b/rukn_altasawoq/quote_engine/processor.py new file mode 100644 index 000000000..54e7fcada --- /dev/null +++ b/rukn_altasawoq/quote_engine/processor.py @@ -0,0 +1,47 @@ +import requests +from bs4 import BeautifulSoup +from rukn_altasawoq.models.schemas import Quote + +def get_product_price_from_url(url: str) -> float: + """ + Fetches the price of a product from a given URL. + This is a placeholder and would need to be adapted for specific websites. + """ + try: + response = requests.get(url) + response.raise_for_status() + soup = BeautifulSoup(response.text, 'html.parser') + + # This is a placeholder for price extraction logic. + # In a real implementation, you would need specific selectors for each site. + # For example, for Amazon, it might be: + # price = soup.find('span', {'id': 'priceblock_ourprice'}).text + # For now, we'll return a dummy price. + return 100.0 + except requests.exceptions.RequestException as e: + print(f"Error fetching product URL: {e}") + return 0.0 + +def create_quote_from_url(customer_id: str, product_url: str) -> Quote: + """ + Creates a quote for a given customer and product URL. + """ + price = get_product_price_from_url(product_url) + + markup = 0.35 # 35% + tax = 0.15 # 15% + + quote_price = price + final_price = price * (1 + markup + tax) + + quote = Quote( + customer_id=customer_id, + product_links=[product_url], + quote_price=quote_price, + markup_percentage=markup * 100, + tax=tax * 100, + final_price=final_price, + status="Pending" + ) + + return quote diff --git a/rukn_altasawoq/services/chatbot_builder_service.py b/rukn_altasawoq/services/chatbot_builder_service.py new file mode 100644 index 000000000..73058e750 --- /dev/null +++ b/rukn_altasawoq/services/chatbot_builder_service.py @@ -0,0 +1,23 @@ +import os +import requests + +class ChatbotBuilderService: + def __init__(self): + self.api_key = os.environ.get("CHATBOT_BUILDER_API_KEY") + self.base_url = "https://api.chatbotbuilder.com" # Replace with actual API base URL + + def send_message(self, user_id: str, message: str): + # Logic to send a message to a user + pass + + def trigger_flow(self, user_id: str, flow_id: str): + # Logic to trigger a flow for a user + pass + + def get_user_data(self, user_id: str): + # Logic to get user data + pass + + def update_user_tags(self, user_id: str, tags: list): + # Logic to update user tags + pass diff --git a/rukn_altasawoq/services/google_sheets_service.py b/rukn_altasawoq/services/google_sheets_service.py new file mode 100644 index 000000000..055af477e --- /dev/null +++ b/rukn_altasawoq/services/google_sheets_service.py @@ -0,0 +1,24 @@ +import os +import gspread +from oauth2client.service_account import ServiceAccountCredentials + +class GoogleSheetsService: + def __init__(self): + scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"] + creds = ServiceAccountCredentials.from_json_keyfile_name(os.environ.get("GOOGLE_SHEETS_CREDENTIALS_PATH"), scope) + self.client = gspread.authorize(creds) + + def get_sheet(self, sheet_name: str): + return self.client.open(sheet_name).sheet1 + + def add_row(self, sheet_name: str, data: list): + sheet = self.get_sheet(sheet_name) + sheet.append_row(data) + + def get_all_records(self, sheet_name: str): + sheet = self.get_sheet(sheet_name) + return sheet.get_all_records() + + def update_cell(self, sheet_name: str, row: int, col: int, value: str): + sheet = self.get_sheet(sheet_name) + sheet.update_cell(row, col, value) diff --git a/rukn_altasawoq/services/notion_service.py b/rukn_altasawoq/services/notion_service.py new file mode 100644 index 000000000..11adf26a6 --- /dev/null +++ b/rukn_altasawoq/services/notion_service.py @@ -0,0 +1,22 @@ +import os +from notion_client import Client + +class NotionService: + def __init__(self): + self.notion = Client(auth=os.environ.get("NOTION_API_KEY")) + + def create_database(self, parent_page_id: str, schema: dict): + # Logic to create a new database in Notion + pass + + def add_entry(self, database_id: str, data: dict): + # Logic to add a new entry to a Notion database + pass + + def query_database(self, database_id: str, filters: dict): + # Logic to query a Notion database + pass + + def update_entry(self, page_id: str, data: dict): + # Logic to update an entry in a Notion database + pass diff --git a/rukn_altasawoq/tests/__pycache__/test_quote_engine.cpython-312.pyc b/rukn_altasawoq/tests/__pycache__/test_quote_engine.cpython-312.pyc new file mode 100644 index 000000000..73fd66a82 Binary files /dev/null and b/rukn_altasawoq/tests/__pycache__/test_quote_engine.cpython-312.pyc differ diff --git a/rukn_altasawoq/tests/test_quote_engine.py b/rukn_altasawoq/tests/test_quote_engine.py new file mode 100644 index 000000000..5e0b17f75 --- /dev/null +++ b/rukn_altasawoq/tests/test_quote_engine.py @@ -0,0 +1,27 @@ +import unittest +from unittest.mock import patch +from rukn_altasawoq.quote_engine.processor import create_quote_from_url + +class TestQuoteEngine(unittest.TestCase): + + @patch('rukn_altasawoq.quote_engine.processor.get_product_price_from_url') + def test_create_quote_from_url(self, mock_get_price): + # Arrange + mock_get_price.return_value = 100.0 + customer_id = "test_customer" + product_url = "http://example.com/product" + + # Act + quote = create_quote_from_url(customer_id, product_url) + + # Assert + self.assertEqual(quote.customer_id, customer_id) + self.assertEqual(quote.product_links, [product_url]) + self.assertEqual(quote.quote_price, 100.0) + self.assertEqual(quote.markup_percentage, 35.0) + self.assertEqual(quote.tax, 15.0) + self.assertEqual(quote.final_price, 150.0) + self.assertEqual(quote.status, "Pending") + +if __name__ == '__main__': + unittest.main()