Skip to content

Commit 21b3fb2

Browse files
committed
initial import
0 parents  commit 21b3fb2

File tree

7 files changed

+6315
-0
lines changed

7 files changed

+6315
-0
lines changed

.gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual environments
24+
.env
25+
.venv
26+
env/
27+
venv/
28+
ENV/
29+
.python-version
30+
31+
# IDE
32+
.idea/
33+
.vscode/
34+
*.swp
35+
*.swo
36+
37+
# OS
38+
.DS_Store

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Beanquery MCP
2+
3+
The Beancount MCP Server is an experimental implementation of the [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol) designed to interface with [Beancount](https://beancount.github.io/) ledger files. Leveraging the [Beancount Query Language (BQL)](https://beancount.github.io/docs/beancount_query_language.html) and the [beanquery](https://github.com/beancount/beanquery) tool, this server enables seamless querying and analysis of financial data stored in Beancount format. By integrating MCP, the server facilitates standardized communication between AI assistants and Beancount ledgers, enhancing the accessibility and utility of financial data.
4+
5+
Note: This server is experimental and may undergo significant changes. It is recommended to use it in a development environment and provide feedback for further improvements.
6+
7+
A generated sample ledger can be found in [sample.bean](sample.bean)
8+
9+
### Available Resources and Tools
10+
11+
- **Tools**:
12+
- `set_ledger_file`: Set the Beancount ledger file to use for queries (if not set via environment variable).
13+
- `run_query`: Run a BQL query against the loaded Beancount file.
14+
- **Resources**:
15+
- `beanquery://tables`: Get a list of tables that BQL can access.
16+
- `beanquery://accounts`: Get a list of accounts in the loaded Beancount file.
17+
18+
## Setup
19+
20+
### Prerequisites
21+
22+
- Python 3.10 or later
23+
- [uv](https://docs.astral.sh/uv/) for managing Python projects (recommended)
24+
25+
## Usage
26+
27+
### Running the Server
28+
29+
1. **Development Mode**:
30+
Use the MCP Inspector to test and debug your server:
31+
```bash
32+
mcp dev server.py
33+
```
34+
35+
2. **Claude Desktop Integration**:
36+
Install the server into Claude Desktop:
37+
```bash
38+
mcp install server.py
39+
```
40+
41+
- **Custom Name**:
42+
```bash
43+
mcp install server.py --name "Beanquery MCP Server"
44+
```
45+
46+
- **Environment Variables**:
47+
```bash
48+
mcp install server.py -v BEANCOUNT_LEDGER=/path/to/your/ledger.bean
49+
mcp install server.py -f .env
50+
```
51+
52+
## Testing
53+
54+
Run the test suite using `pytest`:
55+
```bash
56+
pytest server_test.py
57+
```
58+
59+
## Contributing
60+
61+
1. Fork the repository.
62+
2. Create a feature branch:
63+
```bash
64+
git checkout -b feature-name
65+
```
66+
3. Commit your changes:
67+
```bash
68+
git commit -m "Add feature description"
69+
```
70+
4. Push to your branch:
71+
```bash
72+
git push origin feature-name
73+
```
74+
5. Open a pull request.
75+
76+
## License
77+
78+
This project is licensed under the MIT License. See the `LICENSE` file for details.

pyproject.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "beanquery-mcp"
3+
version = "0.1.0"
4+
description = "The Beancount MCP Server is an experimental implementation that utilizes the Model Context Protocol (MCP) to enable AI assistants to query and analyze Beancount ledger files using Beancount Query Language (BQL) and the beanquery tool."
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"beancount>=3.1.0",
9+
"beanquery>=0.2.0",
10+
"mcp[cli]>=1.5.0",
11+
]
12+
13+
[dependency-groups]
14+
dev = [
15+
"pytest>=8.3.5",
16+
"ruff>=0.8.5",
17+
]
18+
19+
[tool.ruff.lint]
20+
select = ["E", "F", "I", "UP"]
21+
ignore = []
22+
23+
[tool.ruff]
24+
line-length = 88
25+
target-version = "py310"
26+
27+
[tool.pytest.ini_options]
28+
xfail_strict = true

0 commit comments

Comments
 (0)