Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81d786b

Browse files
authored
feat: Update version to 0.1.5, enhance server functionality with streamable HTTP mode, and improve type hints across the codebase (#63)fixes#57
1 parent7ad8f76 commit81d786b

File tree

11 files changed

+468
-279
lines changed

11 files changed

+468
-279
lines changed

‎.gitignore

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
1-
# Build and Distribution
2-
__pycache__/
3-
*.py[cod]
4-
build/
5-
dist/
6-
src/*.egg-info/
7-
8-
# Development Environment
91
.venv/
10-
.env
11-
12-
# IDE
13-
.vscode/
14-
.idea/
15-
.cursor/
16-
.cursorignore
17-
.cursorrules
18-
.specstory
19-
20-
# Testing and Linting
21-
.coverage
22-
.pytest_cache/
23-
.ruff_cache/
24-
.mypy_cache/
25-
htmlcov/
26-
tests/
27-
28-
# Project Files
29-
extras/
2+
dist/
3+
excel_files/
4+
__pycache__/
305
.notes/
31-
logs/
32-
output/
33-
*.xlsx
34-
*.xls
35-
*.log
36-
excel_files/
6+
*.log

‎README.md

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,98 @@
33
</p>
44

55
[![PyPI version](https://img.shields.io/pypi/v/excel-mcp-server.svg)](https://pypi.org/project/excel-mcp-server/)
6-
[![PyPI downloads](https://img.shields.io/pypi/dm/excel-mcp-server.svg)](https://pypi.org/project/excel-mcp-server/)
6+
[![Total Downloads](https://static.pepy.tech/badge/excel-mcp-server)](https://pepy.tech/project/excel-mcp-server)
77
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8+
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=excel-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGV4Y2VsLW1jcC1zZXJ2ZXIgc3RkaW8ifQ%3D%3D)
89

910
A Model Context Protocol (MCP) server that lets you manipulate Excel files without needing Microsoft Excel installed. Create, read, and modify Excel workbooks with your AI agent.
1011

1112
##Features
1213

13-
- 📊 Create and modify Excel workbooks
14-
- 📝 Read and write data
15-
- 🎨 Apply formatting and styles
16-
- 📈 Create charts and visualizations
17-
- 📊 Generate pivot tables
18-
- 🔄 Manage worksheets and ranges
19-
- 🔌 Dual transport support: stdio and SSE
20-
21-
##Quick Start
22-
23-
###Prerequisites
24-
25-
- Python 3.10 or higher
14+
- 📊**Excel Operations**: Create, read, update workbooks and worksheets
15+
- 📈**Data Manipulation**: Formulas, formatting, charts, pivot tables, and Excel tables
16+
- 🔍**Data Validation**: Built-in validation for ranges, formulas, and data integrity
17+
- 🎨**Formatting**: Font styling, colors, borders, alignment, and conditional formatting
18+
- 📋**Table Operations**: Create and manage Excel tables with custom styling
19+
- 📊**Chart Creation**: Generate various chart types (line, bar, pie, scatter, etc.)
20+
- 🔄**Pivot Tables**: Create dynamic pivot tables for data analysis
21+
- 🔧**Sheet Management**: Copy, rename, delete worksheets with ease
22+
- 🔌**Triple transport support**: stdio, SSE (deprecated), and streamable HTTP
23+
- 🌐**Remote & Local**: Works both locally and as a remote service
2624

27-
###Running the Server
25+
##Usage
2826

29-
The server supportstwo transportmodes: stdio and SSE.
27+
The server supportsthree transportmethods:
3028

31-
####Using stdio transport
32-
33-
Stdio transport is ideal for direct integration with tools like Cursor Desktop or local development, which can manipulate local files:
29+
###1. Stdio Transport (for local use)
3430

3531
```bash
3632
uvx excel-mcp-server stdio
3733
```
3834

39-
####Using SSE transport
35+
```json
36+
{
37+
"mcpServers": {
38+
"excel": {
39+
"command":"uvx",
40+
"args": ["excel-mcp-server","stdio"]
41+
}
42+
}
43+
}
44+
```
4045

41-
SSE transport is perfect for remote connections, which manipulate remote files:
46+
###2. SSE Transport (Server-Sent Events - Deprecated)
4247

4348
```bash
4449
uvx excel-mcp-server sse
4550
```
4651

47-
###Add to Cursor
48-
49-
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=excel-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGV4Y2VsLW1jcC1zZXJ2ZXIgc3RkaW8ifQ%3D%3D)
50-
51-
##Using with AI Tools
52-
53-
1. Add this configuration to your client, choosing the appropriate transport method for your needs:
54-
55-
**Stdio transport connection** (for local integration):
52+
**SSE transport connection**:
5653
```json
5754
{
5855
"mcpServers": {
59-
"excel-stdio": {
60-
"command":"uvx",
61-
"args": ["excel-mcp-server","stdio"]
56+
"excel": {
57+
"url":"http://localhost:8000/sse",
6258
}
6359
}
6460
}
6561
```
6662

67-
**SSE transport connection**:
63+
###3. Streamable HTTP Transport (Recommended for remote connections)
64+
65+
```bash
66+
uvx excel-mcp-server streamable-http
67+
```
68+
69+
**Streamable HTTP transport connection**:
6870
```json
6971
{
7072
"mcpServers": {
7173
"excel": {
72-
"url":"http://localhost:8000/sse",
74+
"url":"http://localhost:8000/mcp",
75+
"transport":"streamable-http"
7376
}
7477
}
7578
}
7679
```
7780

78-
2. The Excel tools will be available through your AI assistant.
79-
8081
##Environment Variables & File Path Handling
8182

82-
###SSETransport
83+
###SSEand Streamable HTTP Transports
8384

84-
When running the server with the**SSEprotocol**, you**must set the`EXCEL_FILES_PATH` environment variable on the server side**. This variable tells the server where to read and write Excel files.
85+
When running the server with the**SSEor Streamable HTTP protocols**, you**must set the`EXCEL_FILES_PATH` environment variable on the server side**. This variable tells the server where to read and write Excel files.
8586
- If not set, it defaults to`./excel_files`.
8687

8788
You can also set the`FASTMCP_PORT` environment variable to control the port the server listens on (default is`8000` if not set).
8889
- Example (Windows PowerShell):
8990
```powershell
9091
$env:EXCEL_FILES_PATH="E:\MyExcelFiles"
91-
$env:FASTMCP_PORT="8080"
92-
uvx excel-mcp-serversse
92+
$env:FASTMCP_PORT="8007"
93+
uvx excel-mcp-serverstreamable-http
9394
```
9495
- Example (Linux/macOS):
9596
```bash
96-
EXCEL_FILES_PATH=/path/to/excel_files FASTMCP_PORT=8080 uvx excel-mcp-serversse
97+
EXCEL_FILES_PATH=/path/to/excel_files FASTMCP_PORT=8007 uvx excel-mcp-serverstreamable-http
9798
```
9899

99100
###Stdio Transport
@@ -110,4 +111,4 @@ The server provides a comprehensive set of Excel manipulation tools. See [TOOLS.
110111

111112
##License
112113

113-
MIT License - see[LICENSE](LICENSE) for details.
114+
MIT License - see[LICENSE](LICENSE) for details.

‎assets/logo.png

111 Bytes
Loading

‎assets/logo.svg

Lines changed: 4 additions & 4 deletions
Loading

‎pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
22
name ="excel-mcp-server"
3-
version ="0.1.4"
3+
version ="0.1.5"
44
description ="Excel MCP Server for manipulating Excel files"
55
readme ="README.md"
66
requires-python =">=3.10"
77
dependencies = [
8-
"mcp[cli]>=1.6.0",
9-
"openpyxl>=3.1.2",
10-
"typer>=0.15.1"
8+
"mcp[cli]>=1.10.1",
9+
"openpyxl>=3.1.5",
10+
"typer>=0.16.0"
1111
]
1212
[[project.authors]]
1313
name ="haris"

‎src/excel_mcp/__main__.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
importasyncio
22
importtyper
33

4-
from .serverimportrun_sse,run_stdio
4+
from .serverimportrun_sse,run_stdio,run_streamable_http
55

66
app=typer.Typer(help="Excel MCP Server")
77

@@ -22,9 +22,29 @@ def sse():
2222
finally:
2323
print("Service stopped.")
2424

25+
@app.command()
26+
defstreamable_http():
27+
"""Start Excel MCP Server in streamable HTTP mode"""
28+
print("Excel MCP Server - Streamable HTTP mode")
29+
print("---------------------------------------")
30+
print("Press Ctrl+C to exit")
31+
try:
32+
asyncio.run(run_streamable_http())
33+
exceptKeyboardInterrupt:
34+
print("\nShutting down server...")
35+
exceptExceptionase:
36+
print(f"\nError:{e}")
37+
importtraceback
38+
traceback.print_exc()
39+
finally:
40+
print("Service stopped.")
41+
2542
@app.command()
2643
defstdio():
2744
"""Start Excel MCP Server in stdio mode"""
45+
print("Excel MCP Server - Stdio mode")
46+
print("-----------------------------")
47+
print("Press Ctrl+C to exit")
2848
try:
2949
run_stdio()
3050
exceptKeyboardInterrupt:

‎src/excel_mcp/data.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
frompathlibimportPath
2-
fromtypingimportAny,Dict
2+
fromtypingimportAny,Dict,List,Optional
33
importlogging
44

55
fromopenpyxlimportload_workbook
@@ -16,9 +16,9 @@ def read_excel_range(
1616
filepath:Path|str,
1717
sheet_name:str,
1818
start_cell:str="A1",
19-
end_cell:str|None=None,
19+
end_cell:Optional[str]=None,
2020
preview_only:bool=False
21-
)->list[dict[str,Any]]:
21+
)->List[Dict[str,Any]]:
2222
"""Read data from Excel range with optional preview mode"""
2323
try:
2424
wb=load_workbook(filepath,read_only=False)
@@ -91,10 +91,10 @@ def read_excel_range(
9191

9292
defwrite_data(
9393
filepath:str,
94-
sheet_name:str|None,
95-
data:list[list]|None,
94+
sheet_name:Optional[str],
95+
data:Optional[List[List]],
9696
start_cell:str="A1",
97-
)->dict[str,str]:
97+
)->Dict[str,str]:
9898
"""Write data to Excel sheet with workbook handling
9999
100100
Headers are handled intelligently based on context.
@@ -107,7 +107,10 @@ def write_data(
107107

108108
# If no sheet specified, use active sheet
109109
ifnotsheet_name:
110-
sheet_name=wb.active.title
110+
active_sheet=wb.active
111+
ifactive_sheetisNone:
112+
raiseDataError("No active sheet found in workbook")
113+
sheet_name=active_sheet.title
111114
elifsheet_namenotinwb.sheetnames:
112115
wb.create_sheet(sheet_name)
113116

@@ -137,7 +140,7 @@ def write_data(
137140

138141
def_write_data_to_worksheet(
139142
worksheet:Worksheet,
140-
data:list[list],
143+
data:List[List],
141144
start_cell:str="A1",
142145
)->None:
143146
"""Write data to worksheet with intelligent header handling"""
@@ -168,7 +171,7 @@ def read_excel_range_with_metadata(
168171
filepath:Path|str,
169172
sheet_name:str,
170173
start_cell:str="A1",
171-
end_cell:str|None=None,
174+
end_cell:Optional[str]=None,
172175
include_validation:bool=True
173176
)->Dict[str,Any]:
174177
"""Read data from Excel range with cell metadata including validation rules.

‎src/excel_mcp/formatting.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
importlogging
2-
fromtypingimportAny,Dict
2+
fromtypingimportAny,Dict,Optional
33

44
fromopenpyxl.stylesimport (
55
PatternFill,Border,Side,Alignment,Protection,Font,
@@ -20,21 +20,21 @@ def format_range(
2020
filepath:str,
2121
sheet_name:str,
2222
start_cell:str,
23-
end_cell:str=None,
23+
end_cell:Optional[str]=None,
2424
bold:bool=False,
2525
italic:bool=False,
2626
underline:bool=False,
27-
font_size:int=None,
28-
font_color:str=None,
29-
bg_color:str=None,
30-
border_style:str=None,
31-
border_color:str=None,
32-
number_format:str=None,
33-
alignment:str=None,
27+
font_size:Optional[int]=None,
28+
font_color:Optional[str]=None,
29+
bg_color:Optional[str]=None,
30+
border_style:Optional[str]=None,
31+
border_color:Optional[str]=None,
32+
number_format:Optional[str]=None,
33+
alignment:Optional[str]=None,
3434
wrap_text:bool=False,
3535
merge_cells:bool=False,
36-
protection:Dict[str,Any]=None,
37-
conditional_format:Dict[str,Any]=None
36+
protection:Optional[Dict[str,Any]]=None,
37+
conditional_format:Optional[Dict[str,Any]]=None
3838
)->Dict[str,Any]:
3939
"""Apply formatting to a range of cells.
4040

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp