Merge branch 'main' into community/mcp-server-mysql-on-nodejs

This commit is contained in:
Ian Borla 2024-12-10 03:06:39 +08:00 • committed by GitHub
commit 625247ae3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 129 additions and 38 deletions

View file

@ -34,6 +34,7 @@ These servers aim to demonstrate MCP features and the Typescript and Python SDK.
Official integrations are maintained by companies building production ready MCP servers for their platforms. Official integrations are maintained by companies building production ready MCP servers for their platforms.
- <img height="12" width="12" src="https://axiom.co/favicon.ico" alt="Axiom Logo" /> **[Axiom](https://github.com/axiomhq/mcp-server-axiom)** - Query and analyze your Axiom logs, traces, and all other event data in natural language
- <img height="12" width="12" src="https://browserbase.com/favicon.ico" alt="Browserbase Logo" /> **[Browserbase](https://github.com/browserbase/mcp-server-browserbase)** - Automate browser interactions in the cloud (e.g. web navigation, data extraction, form filling, and more) - <img height="12" width="12" src="https://browserbase.com/favicon.ico" alt="Browserbase Logo" /> **[Browserbase](https://github.com/browserbase/mcp-server-browserbase)** - Automate browser interactions in the cloud (e.g. web navigation, data extraction, form filling, and more)
- <img height="12" width="12" src="https://cdn.simpleicons.org/cloudflare" /> **[Cloudflare](https://github.com/cloudflare/mcp-server-cloudflare)** - Deploy, configure & interrogate your resources on the Cloudflare developer platform (e.g. Workers/KV/R2/D1) - <img height="12" width="12" src="https://cdn.simpleicons.org/cloudflare" /> **[Cloudflare](https://github.com/cloudflare/mcp-server-cloudflare)** - Deploy, configure & interrogate your resources on the Cloudflare developer platform (e.g. Workers/KV/R2/D1)
- **[Raygun](https://github.com/MindscapeHQ/mcp-server-raygun)** - Interact with your crash reporting and real using monitoring data on your Raygun account - **[Raygun](https://github.com/MindscapeHQ/mcp-server-raygun)** - Interact with your crash reporting and real using monitoring data on your Raygun account
@ -51,31 +52,41 @@ A growing set of community-developed and maintained servers demonstrates various
> **Note:** Community servers are **untested** and should be used at **your own risk**. They are not affiliated with or endorsed by Anthropic. > **Note:** Community servers are **untested** and should be used at **your own risk**. They are not affiliated with or endorsed by Anthropic.
- **[MCP Installer](https://github.com/anaisbetts/mcp-installer)** - This server is a server that installs other MCP servers for you. - **[MCP Installer](https://github.com/anaisbetts/mcp-installer)** - This server is a server that installs other MCP servers for you.
- **[Spotify MCP](https://github.com/varunneal/spotify-mcp)** - This MCP allows an LLM to play and use Spotify. - **[Spotify](https://github.com/varunneal/spotify-mcp)** - This MCP allows an LLM to play and use Spotify.
- **[Inoyu](https://github.com/sergehuber/inoyu-mcp-unomi-server)** - Interact with an Apache Unomi CDP customer data platform to retrieve and update customer profiles - **[Inoyu](https://github.com/sergehuber/inoyu-mcp-unomi-server)** - Interact with an Apache Unomi CDP customer data platform to retrieve and update customer profiles
- **[Snowflake](https://github.com/datawiz168/mcp-snowflake-service)** - This MCP server enables LLMs to interact with Snowflake databases, allowing for secure and controlled data operations.
- **[MySQL](https://github.com/designcomputer/mysql_mcp_server)** - (by DesignComputer) MySQL database integration based on Python with configurable access controls and schema inspection - **[MySQL](https://github.com/designcomputer/mysql_mcp_server)** - (by DesignComputer) MySQL database integration based on Python with configurable access controls and schema inspection
- **[MySQL](https://github.com/benborla/mcp-server-mysql)** - (by benborla) MySQL database integration based on NodeJS with configurable access controls and schema inspection - **[MySQL](https://github.com/benborla/mcp-server-mysql)** - (by benborla) MySQL database integration based on NodeJS with configurable access controls and schema inspection
- **[MSSQL](https://github.com/aekanun2020/mcp-server/)** - MSSQL database integration with configurable access controls and schema inspection
- **[BigQuery](https://github.com/LucasHild/mcp-server-bigquery)** (by LucasHild) - This server enables LLMs to inspect database schemas and execute queries on BigQuery. - **[BigQuery](https://github.com/LucasHild/mcp-server-bigquery)** (by LucasHild) - This server enables LLMs to inspect database schemas and execute queries on BigQuery.
- **[BigQuery](https://github.com/ergut/mcp-bigquery-server)** (by ergut) - Server implementation for Google BigQuery integration that enables direct BigQuery database access and querying capabilities - **[BigQuery](https://github.com/ergut/mcp-bigquery-server)** (by ergut) - Server implementation for Google BigQuery integration that enables direct BigQuery database access and querying capabilities
- **[Todoist](https://github.com/abhiz123/todoist-mcp-server)** - Interact with Todoist to manage your tasks. - **[Todoist](https://github.com/abhiz123/todoist-mcp-server)** - Interact with Todoist to manage your tasks.
- **[Tavily search](https://github.com/RamXX/mcp-tavily")** - An MCP server for Tavily's search & news API, with explicit site inclusions/exclusions - **[Tavily search](https://github.com/RamXX/mcp-tavily")** - An MCP server for Tavily's search & news API, with explicit site inclusions/exclusions
- **[Linear](https://github.com/jerhadf/linear-mcp-server)** - Allows LLM to interact with Linear's API for project management, including searching, creating, and updating issues. - **[Linear](https://github.com/jerhadf/linear-mcp-server)** - Allows LLM to interact with Linear's API for project management, including searching, creating, and updating issues.
- **[Playwright MCP](https://github.com/executeautomation/mcp-playwright)** - This MCP Server will help you run browser automation and webscraping using Playwright - **[Playwright](https://github.com/executeautomation/mcp-playwright)** - This MCP Server will help you run browser automation and webscraping using Playwright
- **[AWS](https://github.com/rishikavikondala/mcp-server-aws)** - Perform operations on your AWS resources using an LLM - **[AWS](https://github.com/rishikavikondala/mcp-server-aws)** - Perform operations on your AWS resources using an LLM
- **[LlamaCloud](https://github.com/run-llama/mcp-server-llamacloud)** (by marcusschiesser) - Integrate the data stored in a managed index on [LlamaCloud](https://cloud.llamaindex.ai/) - **[LlamaCloud](https://github.com/run-llama/mcp-server-llamacloud)** (by marcusschiesser) - Integrate the data stored in a managed index on [LlamaCloud](https://cloud.llamaindex.ai/)
- **[Any Chat Completions](https://github.com/pyroprompts/any-chat-completions-mcp)** - Interact with any OpenAI SDK Compatible Chat Completions API like OpenAI, Perplexity, Groq, xAI and many more. - **[Any Chat Completions](https://github.com/pyroprompts/any-chat-completions-mcp)** - Interact with any OpenAI SDK Compatible Chat Completions API like OpenAI, Perplexity, Groq, xAI and many more.
- **[Windows CLI](https://github.com/SimonB97/win-cli-mcp-server)** - MCP server for secure command-line interactions on Windows systems, enabling controlled access to PowerShell, CMD, and Git Bash shells. - **[Windows CLI](https://github.com/SimonB97/win-cli-mcp-server)** - MCP server for secure command-line interactions on Windows systems, enabling controlled access to PowerShell, CMD, and Git Bash shells.
- **[OpenRPC](https://github.com/shanejonas/openrpc-mpc-server)** - Interact with and discover JSON-RPC APIs via [OpenRPC](https://open-rpc.org). - **[OpenRPC](https://github.com/shanejonas/openrpc-mpc-server)** - Interact with and discover JSON-RPC APIs via [OpenRPC](https://open-rpc.org).
- **[FireCrawl](https://github.com/vrknetha/mcp-server-firecrawl)** - Advanced web scraping with JavaScript rendering, PDF support, and smart rate limiting
- **[AlphaVantage](https://github.com/calvernaz/alphavantage)** - MCP server for stock market data API [AlphaVantage](https://www.alphavantage.co)
- **[Docker](https://github.com/ckreiling/mcp-server-docker)** - Integrate with Docker to manage containers, images, volumes, and networks.
- **[Kubernetes](https://github.com/Flux159/mcp-server-kubernetes)** - Connect to Kubernetes cluster and manage pods, deployments, and services.
- **[OpenAPI](https://github.com/snaggle-ai/openapi-mcp-server)** - Interact with [OpenAPI](https://www.openapis.org/) APIs.
- **[Pandoc](https://github.com/vivekVells/mcp-pandoc)** - MCP server for seamless document format conversion using Pandoc, supporting Markdown, HTML, and plain text, with other formats like PDF, csv and docx in development.
## 📚 Resources ## 📚 Resources
Additional resources on MCP. Additional resources on MCP.
- **[Awesome MCP Servers by punkpeye](https://github.com/punkpeye/awesome-mcp-servers)** - A curated list of MCP servers by **[Frank Fiegel](https://github.com/punkpeye)** - **[Awesome MCP Servers by punkpeye](https://github.com/punkpeye/awesome-mcp-servers)** (**[website](https://glama.ai/mcp/servers)**) - A curated list of MCP servers by **[Frank Fiegel](https://github.com/punkpeye)**
- **[Awesome MCP Servers by wong2](https://github.com/wong2/awesome-mcp-servers)** - A curated list of MCP servers by **[wong2](https://github.com/wong2)** - **[Awesome MCP Servers by wong2](https://github.com/wong2/awesome-mcp-servers)** (**[website](https://mcpservers.org)**) - A curated list of MCP servers by **[wong2](https://github.com/wong2)**
- **[Awesome MCP Servers by appcypher](https://github.com/appcypher/awesome-mcp-servers)** - A curated list of MCP servers by **[Stephen Akinyemi](https://github.com/appcypher)** - **[Awesome MCP Servers by appcypher](https://github.com/appcypher/awesome-mcp-servers)** - A curated list of MCP servers by **[Stephen Akinyemi](https://github.com/appcypher)**
- **[Discord Server](https://glama.ai/mcp/discord)** – A community discord server dedicated to MCP by **[Frank Fiegel](https://github.com/punkpeye)**
- **[mcp-get](https://mcp-get.com)** - Command line tool for installing and managing MCP servers by **[Michael Latman](https://github.com/michaellatman)** - **[mcp-get](https://mcp-get.com)** - Command line tool for installing and managing MCP servers by **[Michael Latman](https://github.com/michaellatman)**
- **[mcp-cli](https://github.com/wong2/mcp-cli)** - A CLI inspector for the Model Context Protocol by **[wong2](https://github.com/wong2)** - **[mcp-cli](https://github.com/wong2/mcp-cli)** - A CLI inspector for the Model Context Protocol by **[wong2](https://github.com/wong2)**
- **[r/mcp](https://www.reddit.com/r/mcp)** – A Reddit community dedicated to MCP by **[Frank Fiegel](https://github.com/punkpeye)**
## 🚀 Getting Started ## 🚀 Getting Started

View file

@ -26,34 +26,41 @@ Please note that mcp-server-git is currently in early development. The functiona
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- Returns: Diff output of staged changes - Returns: Diff output of staged changes
4. `git_commit` 4. `git_diff`
- Shows differences between branches or commits
- Inputs:
- `repo_path` (string): Path to Git repository
- `target` (string): Target branch or commit to compare with
- Returns: Diff output comparing current state with target
5. `git_commit`
- Records changes to the repository - Records changes to the repository
- Inputs: - Inputs:
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- `message` (string): Commit message - `message` (string): Commit message
- Returns: Confirmation with new commit hash - Returns: Confirmation with new commit hash
5. `git_add` 6. `git_add`
- Adds file contents to the staging area - Adds file contents to the staging area
- Inputs: - Inputs:
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- `files` (string[]): Array of file paths to stage - `files` (string[]): Array of file paths to stage
- Returns: Confirmation of staged files - Returns: Confirmation of staged files
6. `git_reset` 7. `git_reset`
- Unstages all staged changes - Unstages all staged changes
- Input: - Input:
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- Returns: Confirmation of reset operation - Returns: Confirmation of reset operation
7. `git_log` 8. `git_log`
- Shows the commit logs - Shows the commit logs
- Inputs: - Inputs:
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- `max_count` (number, optional): Maximum number of commits to show (default: 10) - `max_count` (number, optional): Maximum number of commits to show (default: 10)
- Returns: Array of commit entries with hash, author, date, and message - Returns: Array of commit entries with hash, author, date, and message
8. `git_create_branch` 9. `git_create_branch`
- Creates a new branch - Creates a new branch
- Inputs: - Inputs:
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository

View file

@ -24,6 +24,10 @@ class GitDiffUnstaged(BaseModel):
class GitDiffStaged(BaseModel): class GitDiffStaged(BaseModel):
repo_path: str repo_path: str
class GitDiff(BaseModel):
repo_path: str
target: str
class GitCommit(BaseModel): class GitCommit(BaseModel):
repo_path: str repo_path: str
message: str message: str
@ -48,6 +52,7 @@ class GitTools(str, Enum):
STATUS = "git_status" STATUS = "git_status"
DIFF_UNSTAGED = "git_diff_unstaged" DIFF_UNSTAGED = "git_diff_unstaged"
DIFF_STAGED = "git_diff_staged" DIFF_STAGED = "git_diff_staged"
DIFF = "git_diff"
COMMIT = "git_commit" COMMIT = "git_commit"
ADD = "git_add" ADD = "git_add"
RESET = "git_reset" RESET = "git_reset"
@ -63,6 +68,9 @@ def git_diff_unstaged(repo: git.Repo) -> str:
def git_diff_staged(repo: git.Repo) -> str: def git_diff_staged(repo: git.Repo) -> str:
return repo.git.diff("--cached") return repo.git.diff("--cached")
def git_diff(repo: git.Repo, target: str) -> str:
return repo.git.diff(target)
def git_commit(repo: git.Repo, message: str) -> str: def git_commit(repo: git.Repo, message: str) -> str:
commit = repo.index.commit(message) commit = repo.index.commit(message)
return f"Changes committed successfully with hash {commit.hexsha}" return f"Changes committed successfully with hash {commit.hexsha}"
@ -127,6 +135,11 @@ async def serve(repository: Path | None) -> None:
description="Shows changes that are staged for commit", description="Shows changes that are staged for commit",
inputSchema=GitDiffStaged.schema(), inputSchema=GitDiffStaged.schema(),
), ),
Tool(
name=GitTools.DIFF,
description="Shows differences between branches or commits",
inputSchema=GitDiff.schema(),
),
Tool( Tool(
name=GitTools.COMMIT, name=GitTools.COMMIT,
description="Records changes to the repository", description="Records changes to the repository",
@ -210,6 +223,13 @@ async def serve(repository: Path | None) -> None:
text=f"Staged changes:\n{diff}" text=f"Staged changes:\n{diff}"
)] )]
case GitTools.DIFF:
diff = git_diff(repo, arguments["target"])
return [TextContent(
type="text",
text=f"Diff with {arguments['target']}:\n{diff}"
)]
case GitTools.COMMIT: case GitTools.COMMIT:
result = git_commit(repo, arguments["message"]) result = git_commit(repo, arguments["message"])
return [TextContent( return [TextContent(

View file

@ -180,6 +180,14 @@ MCP Server for the GitHub API, enabling file operations, repository management,
- `sha` (optional string): branch name - `sha` (optional string): branch name
- Returns: List of commits - Returns: List of commits
17. `get_issue`
- Gets the contents of an issue within a repository
- Inputs:
- `owner` (string): Repository owner
- `repo` (string): Repository name
- `issue_number` (number): Issue number to retrieve
- Returns: Github Issue object & details
## Search Query Syntax ## Search Query Syntax
### Code Search ### Code Search

View file

@ -20,6 +20,7 @@ import {
CreateRepositorySchema, CreateRepositorySchema,
ForkRepositorySchema, ForkRepositorySchema,
GetFileContentsSchema, GetFileContentsSchema,
GetIssueSchema,
GitHubCommitSchema, GitHubCommitSchema,
GitHubContentSchema, GitHubContentSchema,
GitHubCreateUpdateFileResponseSchema, GitHubCreateUpdateFileResponseSchema,
@ -691,6 +692,29 @@ async function searchUsers(
return SearchUsersResponseSchema.parse(await response.json()); return SearchUsersResponseSchema.parse(await response.json());
} }
async function getIssue(
owner: string,
repo: string,
issueNumber: number
): Promise<GitHubIssue> {
const response = await fetch(
`https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`,
{
headers: {
Authorization: `token ${GITHUB_PERSONAL_ACCESS_TOKEN}`,
Accept: "application/vnd.github.v3+json",
"User-Agent": "github-mcp-server",
},
}
);
if (!response.ok) {
throw new Error(`Github API error: ${response.statusText}`);
}
return GitHubIssueSchema.parse(await response.json());
}
server.setRequestHandler(ListToolsRequestSchema, async () => { server.setRequestHandler(ListToolsRequestSchema, async () => {
return { return {
tools: [ tools: [
@ -778,6 +802,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
description: "Search for users on GitHub", description: "Search for users on GitHub",
inputSchema: zodToJsonSchema(SearchUsersSchema), inputSchema: zodToJsonSchema(SearchUsersSchema),
}, },
{
name: "get_issue",
description: "Get details of a specific issue in a GitHub repository.",
inputSchema: zodToJsonSchema(GetIssueSchema)
}
], ],
}; };
}); });
@ -972,6 +1001,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] }; return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] };
} }
case "get_issue": {
const args = z.object({
owner: z.string(),
repo: z.string(),
issue_number: z.number()
}).parse(request.params.arguments);
const issue = await getIssue(args.owner, args.repo, args.issue_number);
return { toolResult: issue };
}
default: default:
throw new Error(`Unknown tool: ${request.params.name}`); throw new Error(`Unknown tool: ${request.params.name}`);
} }

View file

@ -677,6 +677,12 @@ export const IssueCommentSchema = z.object({
body: z.string() body: z.string()
}); });
export const GetIssueSchema = z.object({
owner: z.string().describe("Repository owner (username or organization)"),
repo: z.string().describe("Repository name"),
issue_number: z.number().describe("Issue number")
});
// Export types // Export types
export type GitHubAuthor = z.infer<typeof GitHubAuthorSchema>; export type GitHubAuthor = z.infer<typeof GitHubAuthorSchema>;
export type GitHubFork = z.infer<typeof GitHubForkSchema>; export type GitHubFork = z.infer<typeof GitHubForkSchema>;

View file

@ -6,7 +6,7 @@ A Model Context Protocol server for retrieving and analyzing issues from Sentry.
### Tools ### Tools
1. `get-sentry-issue` 1. `get_sentry_issue`
- Retrieve and analyze a Sentry issue by ID or URL - Retrieve and analyze a Sentry issue by ID or URL
- Input: - Input:
- `issue_id_or_url` (string): Sentry issue ID or URL to analyze - `issue_id_or_url` (string): Sentry issue ID or URL to analyze

View file

@ -223,7 +223,7 @@ async def serve(auth_token: str) -> Server:
async def handle_list_tools() -> list[types.Tool]: async def handle_list_tools() -> list[types.Tool]:
return [ return [
types.Tool( types.Tool(
name="get-sentry-issue", name="get_sentry_issue",
description="""Retrieve and analyze a Sentry issue by ID or URL. Use this tool when you need to: description="""Retrieve and analyze a Sentry issue by ID or URL. Use this tool when you need to:
- Investigate production errors and crashes - Investigate production errors and crashes
- Access detailed stacktraces from Sentry - Access detailed stacktraces from Sentry
@ -247,7 +247,7 @@ async def serve(auth_token: str) -> Server:
async def handle_call_tool( async def handle_call_tool(
name: str, arguments: dict | None name: str, arguments: dict | None
) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
if name != "get-sentry-issue": if name != "get_sentry_issue":
raise ValueError(f"Unknown tool: {name}") raise ValueError(f"Unknown tool: {name}")
if not arguments or "issue_id_or_url" not in arguments: if not arguments or "issue_id_or_url" not in arguments:

View file

@ -22,26 +22,26 @@ The server provides a demonstration prompt:
The server offers six core tools: The server offers six core tools:
#### Query Tools #### Query Tools
- `read-query` - `read_query`
- Execute SELECT queries to read data from the database - Execute SELECT queries to read data from the database
- Input: - Input:
- `query` (string): The SELECT SQL query to execute - `query` (string): The SELECT SQL query to execute
- Returns: Query results as array of objects - Returns: Query results as array of objects
- `write-query` - `write_query`
- Execute INSERT, UPDATE, or DELETE queries - Execute INSERT, UPDATE, or DELETE queries
- Input: - Input:
- `query` (string): The SQL modification query - `query` (string): The SQL modification query
- Returns: `{ affected_rows: number }` - Returns: `{ affected_rows: number }`
- `create-table` - `create_table`
- Create new tables in the database - Create new tables in the database
- Input: - Input:
- `query` (string): CREATE TABLE SQL statement - `query` (string): CREATE TABLE SQL statement
- Returns: Confirmation of table creation - Returns: Confirmation of table creation
#### Schema Tools #### Schema Tools
- `list-tables` - `list_tables`
- Get a list of all tables in the database - Get a list of all tables in the database
- No input required - No input required
- Returns: Array of table names - Returns: Array of table names
@ -53,7 +53,7 @@ The server offers six core tools:
- Returns: Array of column definitions with names and types - Returns: Array of column definitions with names and types
#### Analysis Tools #### Analysis Tools
- `append-insight` - `append_insight`
- Add new business insights to the memo resource - Add new business insights to the memo resource
- Input: - Input:
- `insight` (string): Business insight discovered from data analysis - `insight` (string): Business insight discovered from data analysis

View file

@ -27,12 +27,12 @@ Resources:
This server exposes one key resource: "memo://insights", which is a business insights memo that gets automatically updated throughout the analysis process. As users analyze the database and discover insights, the memo resource gets updated in real-time to reflect new findings. Resources act as living documents that provide context to the conversation. This server exposes one key resource: "memo://insights", which is a business insights memo that gets automatically updated throughout the analysis process. As users analyze the database and discover insights, the memo resource gets updated in real-time to reflect new findings. Resources act as living documents that provide context to the conversation.
Tools: Tools:
This server provides several SQL-related tools: This server provides several SQL-related tools:
"read-query": Executes SELECT queries to read data from the database "read_query": Executes SELECT queries to read data from the database
"write-query": Executes INSERT, UPDATE, or DELETE queries to modify data "write_query": Executes INSERT, UPDATE, or DELETE queries to modify data
"create-table": Creates new tables in the database "create_table": Creates new tables in the database
"list-tables": Shows all existing tables "list_tables": Shows all existing tables
"describe-table": Shows the schema for a specific table "describe_table": Shows the schema for a specific table
"append-insight": Adds a new business insight to the memo resource "append_insight": Adds a new business insight to the memo resource
</mcp> </mcp>
<demo-instructions> <demo-instructions>
You are an AI assistant tasked with generating a comprehensive business scenario based on a given topic. You are an AI assistant tasked with generating a comprehensive business scenario based on a given topic.
@ -68,7 +68,7 @@ a. Present 1 additional multiple-choice query options to the user. Its important
b. Explain the purpose of each query option. b. Explain the purpose of each query option.
c. Wait for the user to select one of the query options. c. Wait for the user to select one of the query options.
d. After each query be sure to opine on the results. d. After each query be sure to opine on the results.
e. Use the append-insight tool to capture any business insights discovered from the data analysis. e. Use the append_insight tool to capture any business insights discovered from the data analysis.
7. Generate a dashboard: 7. Generate a dashboard:
a. Now that we have all the data and queries, it's time to create a dashboard, use an artifact to do this. a. Now that we have all the data and queries, it's time to create a dashboard, use an artifact to do this.
@ -233,7 +233,7 @@ async def main(db_path: str):
"""List available tools""" """List available tools"""
return [ return [
types.Tool( types.Tool(
name="read-query", name="read_query",
description="Execute a SELECT query on the SQLite database", description="Execute a SELECT query on the SQLite database",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -244,7 +244,7 @@ async def main(db_path: str):
}, },
), ),
types.Tool( types.Tool(
name="write-query", name="write_query",
description="Execute an INSERT, UPDATE, or DELETE query on the SQLite database", description="Execute an INSERT, UPDATE, or DELETE query on the SQLite database",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -255,7 +255,7 @@ async def main(db_path: str):
}, },
), ),
types.Tool( types.Tool(
name="create-table", name="create_table",
description="Create a new table in the SQLite database", description="Create a new table in the SQLite database",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -266,7 +266,7 @@ async def main(db_path: str):
}, },
), ),
types.Tool( types.Tool(
name="list-tables", name="list_tables",
description="List all tables in the SQLite database", description="List all tables in the SQLite database",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -274,7 +274,7 @@ async def main(db_path: str):
}, },
), ),
types.Tool( types.Tool(
name="describe-table", name="describe_table",
description="Get the schema information for a specific table", description="Get the schema information for a specific table",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -285,7 +285,7 @@ async def main(db_path: str):
}, },
), ),
types.Tool( types.Tool(
name="append-insight", name="append_insight",
description="Add a business insight to the memo", description="Add a business insight to the memo",
inputSchema={ inputSchema={
"type": "object", "type": "object",
@ -303,13 +303,13 @@ async def main(db_path: str):
) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
"""Handle tool execution requests""" """Handle tool execution requests"""
try: try:
if name == "list-tables": if name == "list_tables":
results = db._execute_query( results = db._execute_query(
"SELECT name FROM sqlite_master WHERE type='table'" "SELECT name FROM sqlite_master WHERE type='table'"
) )
return [types.TextContent(type="text", text=str(results))] return [types.TextContent(type="text", text=str(results))]
elif name == "describe-table": elif name == "describe_table":
if not arguments or "table_name" not in arguments: if not arguments or "table_name" not in arguments:
raise ValueError("Missing table_name argument") raise ValueError("Missing table_name argument")
results = db._execute_query( results = db._execute_query(
@ -317,7 +317,7 @@ async def main(db_path: str):
) )
return [types.TextContent(type="text", text=str(results))] return [types.TextContent(type="text", text=str(results))]
elif name == "append-insight": elif name == "append_insight":
if not arguments or "insight" not in arguments: if not arguments or "insight" not in arguments:
raise ValueError("Missing insight argument") raise ValueError("Missing insight argument")
@ -332,19 +332,19 @@ async def main(db_path: str):
if not arguments: if not arguments:
raise ValueError("Missing arguments") raise ValueError("Missing arguments")
if name == "read-query": if name == "read_query":
if not arguments["query"].strip().upper().startswith("SELECT"): if not arguments["query"].strip().upper().startswith("SELECT"):
raise ValueError("Only SELECT queries are allowed for read-query") raise ValueError("Only SELECT queries are allowed for read_query")
results = db._execute_query(arguments["query"]) results = db._execute_query(arguments["query"])
return [types.TextContent(type="text", text=str(results))] return [types.TextContent(type="text", text=str(results))]
elif name == "write-query": elif name == "write_query":
if arguments["query"].strip().upper().startswith("SELECT"): if arguments["query"].strip().upper().startswith("SELECT"):
raise ValueError("SELECT queries are not allowed for write-query") raise ValueError("SELECT queries are not allowed for write_query")
results = db._execute_query(arguments["query"]) results = db._execute_query(arguments["query"])
return [types.TextContent(type="text", text=str(results))] return [types.TextContent(type="text", text=str(results))]
elif name == "create-table": elif name == "create_table":
if not arguments["query"].strip().upper().startswith("CREATE TABLE"): if not arguments["query"].strip().upper().startswith("CREATE TABLE"):
raise ValueError("Only CREATE TABLE statements are allowed") raise ValueError("Only CREATE TABLE statements are allowed")
db._execute_query(arguments["query"]) db._execute_query(arguments["query"])