Skip to content

Migrate Jira and Salesforce examples from plugins to Python endpoints #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions examples/jira/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# MXCP Jira Plugin Example
# MXCP Jira Python Endpoints Example

This example demonstrates how to use MXCP with Jira data. It shows how to:
- Create and use a custom MXCP plugin for Jira integration
- Query Jira data using SQL
- Combine Jira data with other data sources
This example demonstrates how to use MXCP with Jira data using Python endpoints. This approach uses Python functions directly as MCP tools.

## Overview

The plugin provides several UDFs that allow you to:
This example provides Python MCP endpoints that allow you to:
- Execute JQL queries to search issues
- Get detailed information for specific issues
- Get user information
- List projects and their details
- Get project metadata

## Implementation Approach

This example uses Python functions that are exposed as MCP tools:
- Python functions handle the Jira API interactions
- Tool definitions map to these Python functions
- Results are returned as JSON data

## Configuration

### 1. Creating an Atlassian API Token
Expand All @@ -29,7 +34,7 @@ To create an API token without scopes:

3. **Create the API token**:
- Click **"Create API token"** (not "Create API token with scopes")
- Enter a descriptive name for your token (e.g., "MXCP Jira Integration")
- Enter a descriptive name for your token (e.g., "MXCP Jira Python Integration")
- Select an expiration date (tokens can last from 1 day to 1 year)
- Click **"Create"**

Expand All @@ -40,106 +45,101 @@ To create an API token without scopes:

### 2. User Configuration

Add the following to your MXCP user config (`~/.mxcp/config.yml`). You can use the example `config.yml` in this directory as a template:
Add the following to your MXCP user config (`~/.mxcp/config.yml`):

```yaml
mxcp: 1

projects:
jira-demo:
profiles:
dev:
plugin:
config:
jira:
default:
secrets:
- name: "jira"
type: "python"
parameters:
url: "https://your-domain.atlassian.net"
username: "your-email@example.com"
password: "your-api-token" # Use the API token you created above
```

**Configuration Notes:**
- Replace `your-domain` with your actual Atlassian domain
- Replace `your-email@example.com` with the email address of your Atlassian account
- Replace `your-api-token` with the API token you created in step 1
- The `password` field should contain your API token, not your actual Atlassian password

### 2. Site Configuration
### 3. Site Configuration

Create an `mxcp-site.yml` file:

```yaml
mxcp: 1
project: jira-demo
profile: dev
plugin:
- name: jira
module: mxcp_plugin_jira
config: jira
profile: default
secrets:
- jira
```

## Available Tools

### JQL Query
```sql
-- Execute a JQL query to search issues
SELECT jql_query_jira($jql, $limit) as result;
Execute JQL queries:
```bash
mxcp run tool jql_query --param query="project = TEST" --param limit=10
```

### Get Issue
Get detailed information for a specific issue by its key:
```bash
mxcp run tool get_issue --param issue_key="RD-123"
```

### Get User
```sql
-- Get user information
SELECT get_user_jira($username) as result;
Get a specific user by their account ID:
```bash
mxcp run tool get_user --param account_id="557058:ab168c94-8485-405c-88e6-6458375eb30b"
```

### Search Users
Search for users by name, email, or other criteria:
```bash
mxcp run tool search_user --param query="john.doe@example.com"
```

### List Projects
```sql
-- List all projects
SELECT list_projects_jira($project_name) as result;
List all projects:
```bash
mxcp run tool list_projects
```

### Get Project
```sql
-- Get project details
SELECT get_project_jira($project_key) as result;
Get project details:
```bash
mxcp run tool get_project --param project_key="TEST"
```

## Example Queries

1. Query issues with their assignees:
```sql
WITH issues AS (
SELECT * FROM jql_query_jira('project = "PROJ" ORDER BY created DESC', 100)
)
SELECT
i.key as issue_key,
i.fields.summary as summary,
i.fields.assignee.displayName as assignee
FROM issues i;
### Get Project Roles
Get all roles available in a project:
```bash
mxcp run tool get_project_roles --param project_key="TEST"
```

## Plugin Development

The `mxcp_plugin_jira` directory contains a complete MXCP plugin implementation that you can use as a reference for creating your own plugins. It demonstrates:

- Plugin class structure
- Type conversion
- UDF implementation
- Configuration handling

## Running the Example

1. Set the `MXCP_CONFIG` environment variable to point to your config file:
```bash
export MXCP_CONFIG=/path/to/examples/jira/config.yml
```

2. Start the MXCP server:
```bash
mxcp serve
```
### Get Project Role Users
Get users and groups for a specific role in a project:
```bash
mxcp run tool get_project_role_users --param project_key="TEST" --param role_name="Developers"
```

## Notes
## Project Structure

- Make sure to keep your API token secure and never commit it to version control.
- The plugin requires proper authentication and API permissions to work with your Jira instance.
- All functions return JSON strings containing the requested data.
```
jira-python/
├── mxcp-site.yml # Site configuration
├── python/ # Python implementations
│ └── jira_endpoints.py # All JIRA endpoint functions
├── tools/ # Tool definitions
│ ├── jql_query.yml
│ ├── get_issue.yml
│ ├── get_user.yml
│ ├── search_user.yml
│ ├── list_projects.yml
│ ├── get_project.yml
│ ├── get_project_roles.yml
│ └── get_project_role_users.yml
└── README.md
```
19 changes: 12 additions & 7 deletions examples/jira/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
mxcp: 1

# Sample configuration file for JIRA Python endpoints example
# Copy this to ~/.mxcp/config.yml and update with your JIRA details

projects:
jira-demo:
profiles:
dev:
plugin:
config:
jira:
url: "https://your-domain.atlassian.net"
username: "your-email@example.com"
password: "your-api-token"
default:
secrets:
- name: "jira"
type: "python"
parameters:
url: "${JIRA_URL}"
username: "${JIRA_USERNAME}"
password: "${JIRA_API_TOKEN}"

8 changes: 3 additions & 5 deletions examples/jira/mxcp-site.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mxcp: 1
project: jira-demo
profile: dev
plugin:
- name: jira
module: mxcp_plugin_jira
config: jira
profile: default
secrets:
- jira
9 changes: 0 additions & 9 deletions examples/jira/plugins/mxcp_plugin_jira/__init__.py

This file was deleted.

Loading
Loading