-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from modelcontextprotocol/sqlite-server
Added SQLite Notes To Do Server
- Loading branch information
Showing
7 changed files
with
737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Simple SQLite Notes Server | ||
|
||
A basic MCP server implementation that demonstrates note-taking functionality using the three core MCP primitives: Resources, Prompts, and Tools. | ||
|
||
## Core Concepts | ||
|
||
### Resources | ||
Resources are how clients access data from the server. In this case, they're notes stored in SQLite. | ||
|
||
```python | ||
# Access notes through a custom URI scheme | ||
note:///example_note # Gets the content of 'example_note' | ||
``` | ||
|
||
### Prompts | ||
Prompts allow generating text based on server state. Our server has a note summarization prompt that can be styled. | ||
|
||
```python | ||
# Example prompt with style argument | ||
{ | ||
"name": "summarize-notes", | ||
"arguments": { | ||
"style": "academic" # Can be any style descriptor | ||
} | ||
} | ||
``` | ||
|
||
### Tools | ||
Tools modify server state. We have a simple tool to add new notes. | ||
|
||
```python | ||
# Adding a new note | ||
{ | ||
"name": "add-note", | ||
"arguments": { | ||
"name": "my_note", | ||
"content": "This is my note content" | ||
} | ||
} | ||
``` | ||
|
||
## Key Implementation Details | ||
|
||
### Handler Registration | ||
All decorated handlers must be inside `__init__`: | ||
```python | ||
def __init__(self): | ||
super().__init__("sqlite") | ||
|
||
@self.list_resources() | ||
async def handle_list_resources(): | ||
# Handler code here | ||
|
||
@self.read_resource() | ||
async def handle_read_resource(): | ||
# Handler code here | ||
``` | ||
|
||
### Storage | ||
- Uses SQLite for persistent storage | ||
- Helper methods handle database operations | ||
- Clients are notified of state changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[project] | ||
name = "sqlite" | ||
version = "0.1.0" | ||
description = "A simple SQLite MCP server" | ||
readme = "README.md" | ||
requires-python = ">=3.11" | ||
dependencies = [ | ||
"mcp>=0.9.0", | ||
] | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project.scripts] | ||
sqlite = "sqlite:main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from . import server | ||
import asyncio | ||
|
||
def main(): | ||
"""Main entry point for the package.""" | ||
asyncio.run(server.main()) | ||
|
||
# Optionally expose other important items at package level | ||
__all__ = ['main', 'server'] |
Oops, something went wrong.