Skip to content

Commit c849cd5

Browse files
committed
JIRA and Salesforce examples rewritten in Python
1 parent 657d7b7 commit c849cd5

29 files changed

+1562
-577
lines changed

examples/jira/README.md

Lines changed: 147 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,214 @@
1-
# MXCP Jira Plugin Example
1+
# MXCP Jira Python Endpoints Example
22

3-
This example demonstrates how to use MXCP with Jira data. It shows how to:
4-
- Create and use a custom MXCP plugin for Jira integration
5-
- Query Jira data using SQL
6-
- Combine Jira data with other data sources
3+
This example demonstrates how to use MXCP with Jira data using **plain Python endpoints** instead of plugins. This approach is simpler, more direct, and easier to debug than the plugin-based approach.
74

85
## Overview
96

10-
The plugin provides several UDFs that allow you to:
7+
This example provides Python MCP endpoints that allow you to:
118
- Execute JQL queries to search issues
9+
- Get detailed information for specific issues
1210
- Get user information
1311
- List projects and their details
1412
- Get project metadata
1513

14+
## Key Differences from Plugin Approach
15+
16+
- **No custom plugins required** - just plain Python functions
17+
- **Direct MCP tool calls** - no SQL wrapper layer needed
18+
- **Simpler configuration** - no plugin registration required
19+
- **Easier debugging** - standard Python debugging works naturally
20+
- **More flexible** - can return any JSON-serializable data
21+
1622
## Configuration
1723

1824
### 1. Creating an Atlassian API Token
1925

20-
**Important:** This plugin currently only supports API tokens **without scopes**. While Atlassian has introduced scoped API tokens, there are known compatibility issues when using scoped tokens with basic authentication that this plugin relies on.
21-
22-
To create an API token without scopes:
26+
Follow the same process as the plugin example:
2327

2428
1. **Log in to your Atlassian account** at [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens)
2529

26-
2. **Verify your identity** (if prompted):
27-
- Atlassian may ask you to verify your identity before creating API tokens
28-
- Check your email for a one-time passcode and enter it when prompted
29-
30-
3. **Create the API token**:
30+
2. **Create the API token**:
3131
- Click **"Create API token"** (not "Create API token with scopes")
32-
- Enter a descriptive name for your token (e.g., "MXCP Jira Integration")
33-
- Select an expiration date (tokens can last from 1 day to 1 year)
32+
- Enter a descriptive name for your token (e.g., "MXCP Jira Python Integration")
33+
- Select an expiration date
3434
- Click **"Create"**
3535

36-
4. **Copy and save your token**:
37-
- Click **"Copy to clipboard"** to copy the token
38-
- **Important:** Save this token securely (like in a password manager) as you won't be able to view it again
39-
- This token will be used as your "password" in the configuration below
36+
3. **Copy and save your token** securely
4037

4138
### 2. User Configuration
4239

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

4542
```yaml
4643
mxcp: 1
4744

4845
projects:
49-
jira-demo:
46+
jira-python-demo:
5047
profiles:
51-
dev:
52-
plugin:
53-
config:
54-
jira:
48+
default:
49+
secrets:
50+
# JIRA credentials - using "python" type to demonstrate behavior
51+
- name: "jira"
52+
type: "python" # This will cause DuckDB injection to fail (but continue gracefully)
53+
parameters:
5554
url: "https://your-domain.atlassian.net"
5655
username: "your-email@example.com"
5756
password: "your-api-token" # Use the API token you created above
5857
```
5958
60-
**Configuration Notes:**
61-
- Replace `your-domain` with your actual Atlassian domain
62-
- Replace `your-email@example.com` with the email address of your Atlassian account
63-
- Replace `your-api-token` with the API token you created in step 1
64-
- The `password` field should contain your API token, not your actual Atlassian password
59+
### Experimental Setup: DuckDB Secret Injection
60+
61+
This example is set up to demonstrate what happens when:
62+
1. **Secret is required** - Listed in `mxcp-site.yml`'s `secrets` array
63+
2. **Invalid DuckDB type** - Using `type: "python"` which DuckDB doesn't understand
64+
65+
**Expected behavior:**
66+
- DuckDB injection will fail during startup (logged as debug message)
67+
- Python endpoints will still work perfectly via `config.get_secret()`
68+
- Server will continue running normally
69+
70+
This shows MXCP's graceful handling of unsupported secret types!
6571

66-
### 2. Site Configuration
72+
### 3. Site Configuration
6773

6874
Create an `mxcp-site.yml` file:
6975

7076
```yaml
7177
mxcp: 1
72-
project: jira-demo
73-
profile: dev
74-
plugin:
75-
- name: jira
76-
module: mxcp_plugin_jira
77-
config: jira
78+
project: jira-python-demo
79+
profile: default
80+
secrets:
81+
- jira # This forces the secret to be injected into DuckDB
7882
```
7983

84+
Note: We're listing the JIRA secret as required to demonstrate DuckDB injection behavior.
85+
8086
## Available Tools
8187

8288
### JQL Query
83-
```sql
84-
-- Execute a JQL query to search issues
85-
SELECT jql_query_jira($jql, $limit) as result;
89+
Execute JQL queries directly as Python function calls:
90+
```bash
91+
mxcp run tool jql_query --param query="project = TEST" --param limit=10
92+
```
93+
94+
### Get Issue
95+
Get detailed information for a specific issue by its key:
96+
```bash
97+
mxcp run tool get_issue --param issue_key="RD-123"
8698
```
8799

88100
### Get User
89-
```sql
90-
-- Get user information
91-
SELECT get_user_jira($username) as result;
101+
Get a specific user by their account ID:
102+
```bash
103+
mxcp run tool get_user --param account_id="557058:ab168c94-8485-405c-88e6-6458375eb30b"
104+
```
105+
106+
### Search Users
107+
Search for users by name, email, or other criteria:
108+
```bash
109+
mxcp run tool search_user --param query="john.doe@example.com"
92110
```
93111

94112
### List Projects
95-
```sql
96-
-- List all projects
97-
SELECT list_projects_jira($project_name) as result;
113+
List all projects:
114+
```bash
115+
mxcp run tool list_projects
98116
```
99117

100118
### Get Project
101-
```sql
102-
-- Get project details
103-
SELECT get_project_jira($project_key) as result;
119+
Get project details:
120+
```bash
121+
mxcp run tool get_project --param project_key="TEST"
104122
```
105123

106-
## Example Queries
107-
108-
1. Query issues with their assignees:
109-
```sql
110-
WITH issues AS (
111-
SELECT * FROM jql_query_jira('project = "PROJ" ORDER BY created DESC', 100)
112-
)
113-
SELECT
114-
i.key as issue_key,
115-
i.fields.summary as summary,
116-
i.fields.assignee.displayName as assignee
117-
FROM issues i;
124+
### Get Project Roles
125+
Get all roles available in a project:
126+
```bash
127+
mxcp run tool get_project_roles --param project_key="TEST"
118128
```
119129

120-
## Plugin Development
121-
122-
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:
130+
### Get Project Role Users
131+
Get users and groups for a specific role in a project:
132+
```bash
133+
mxcp run tool get_project_role_users --param project_key="TEST" --param role_name="Developers"
134+
```
123135

124-
- Plugin class structure
125-
- Type conversion
126-
- UDF implementation
127-
- Configuration handling
128136

129-
## Running the Example
130137

131-
1. Set the `MXCP_CONFIG` environment variable to point to your config file:
132-
```bash
133-
export MXCP_CONFIG=/path/to/examples/jira/config.yml
134-
```
138+
## Example Usage
135139

136-
2. Start the MXCP server:
140+
1. Start the MXCP server:
137141
```bash
138142
mxcp serve
139143
```
140144

145+
2. Or run tools directly:
146+
```bash
147+
# Query recent issues
148+
mxcp run tool jql_query --param query="project = TEST ORDER BY created DESC" --param limit=5
149+
150+
# Get specific issue details
151+
mxcp run tool get_issue --param issue_key="RD-123"
152+
153+
# Get specific user by account ID
154+
mxcp run tool get_user --param account_id="557058:ab168c94-8485-405c-88e6-6458375eb30b"
155+
156+
# Search for users
157+
mxcp run tool search_user --param query="admin"
158+
159+
# List all projects
160+
mxcp run tool list_projects
161+
162+
# Get specific project
163+
mxcp run tool get_project --param project_key="TEST"
164+
165+
# Get project roles
166+
mxcp run tool get_project_roles --param project_key="TEST"
167+
168+
# Get users for specific role
169+
mxcp run tool get_project_role_users --param project_key="TEST" --param role_name="Developers"
170+
```
171+
172+
## Project Structure
173+
174+
```
175+
jira-python/
176+
├── mxcp-site.yml # Simple site configuration
177+
├── python/ # Python implementations
178+
│ └── jira_endpoints.py # All JIRA endpoint functions
179+
├── tools/ # Tool definitions
180+
│ ├── jql_query.yml
181+
│ ├── get_issue.yml
182+
│ ├── get_user.yml
183+
│ ├── search_user.yml
184+
│ ├── list_projects.yml
185+
│ ├── get_project.yml
186+
│ ├── get_project_roles.yml
187+
│ └── get_project_role_users.yml
188+
└── README.md
189+
```
190+
191+
## Key Features
192+
193+
- **Direct Python Functions**: No SQL wrapper layer needed
194+
- **Async Support**: Functions can be async for better performance
195+
- **Database Integration**: Can optionally store results in DuckDB
196+
- **Error Handling**: Proper error responses for invalid requests
197+
- **Type Safety**: Full type hints for better IDE support
198+
- **Logging**: Comprehensive logging for debugging
199+
200+
## Migration from Plugin Approach
201+
202+
This example demonstrates how much simpler the Python endpoint approach is:
203+
204+
- **Plugin approach**: Plugin class → UDFs → SQL calls → Tool definitions
205+
- **Python approach**: Python functions → Tool definitions
206+
207+
The functionality is identical, but the implementation is much more straightforward!
208+
141209
## Notes
142210
143-
- Make sure to keep your API token secure and never commit it to version control.
144-
- The plugin requires proper authentication and API permissions to work with your Jira instance.
145-
- All functions return JSON strings containing the requested data.
211+
- Make sure to keep your API token secure and never commit it to version control
212+
- The plugin requires proper authentication and API permissions to work with your Jira instance
213+
- Functions return JSON data that can be directly used by MCP clients
214+
- Results can optionally be stored in DuckDB for further SQL analysis

examples/jira/config.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
mxcp: 1
22

3+
# Sample configuration file for JIRA Python endpoints example
4+
# Copy this to ~/.mxcp/config.yml and update with your JIRA details
5+
36
projects:
4-
jira-demo:
7+
jira-python-demo:
58
profiles:
6-
dev:
7-
plugin:
8-
config:
9-
jira:
9+
default:
10+
secrets:
11+
- name: "jira"
12+
type: "python"
13+
parameters:
1014
url: "https://your-domain.atlassian.net"
1115
username: "your-email@example.com"
12-
password: "your-api-token"
16+
password: "your-api-token"
17+

examples/jira/mxcp-site.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
mxcp: 1
2-
project: jira-demo
3-
profile: dev
4-
plugin:
5-
- name: jira
6-
module: mxcp_plugin_jira
7-
config: jira
2+
project: jira-python-demo
3+
profile: default
4+
secrets:
5+
- jira

examples/jira/plugins/mxcp_plugin_jira/__init__.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)