Skip to content

Commit 9f260c1

Browse files
committed
fix: ignore type error
Until modelcontextprotocol/python-sdk#355 is solved, we should ignore type errors around AppContext.
1 parent 3be6e4d commit 9f260c1

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/mcp_bear/server.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from fastapi import FastAPI, Request
2121
from mcp.server import FastMCP
2222
from mcp.server.fastmcp import Context
23-
from mcp.server.session import ServerSessionT
2423
from pydantic import Field
2524
from starlette.datastructures import QueryParams
2625
from uvicorn import Config, Server
@@ -120,12 +119,12 @@ async def app_lifespan(_server: FastMCP) -> AsyncIterator[AppContext]:
120119

121120
@mcp.tool()
122121
async def open_note(
123-
ctx: Context[ServerSessionT, AppContext],
122+
ctx: Context,
124123
id: str | None = Field(description="note unique identifier", default=None),
125124
title: str | None = Field(description="note title", default=None),
126125
) -> str:
127126
"""Open a note identified by its title or id and return its content."""
128-
app_ctx = ctx.request_context.lifespan_context
127+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
129128
future = Future[QueryParams]()
130129
await app_ctx.open_note_results.put(future)
131130

@@ -152,14 +151,14 @@ async def open_note(
152151

153152
@mcp.tool()
154153
async def create(
155-
ctx: Context[ServerSessionT, AppContext],
154+
ctx: Context,
156155
title: str | None = Field(description="note title", default=None),
157156
text: str | None = Field(description="note body", default=None),
158157
tags: list[str] | None = Field(description="list of tags", default=None),
159158
timestamp: bool = Field(description="prepend the current date and time to the text", default=False),
160159
) -> str:
161160
"""Create a new note and return its unique identifier. Empty notes are not allowed."""
162-
app_ctx = ctx.request_context.lifespan_context
161+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
163162
future = Future[QueryParams]()
164163
await app_ctx.create_results.put(future)
165164

@@ -187,10 +186,10 @@ async def create(
187186

188187
@mcp.tool()
189188
async def tags(
190-
ctx: Context[ServerSessionT, AppContext],
189+
ctx: Context,
191190
) -> list[str]:
192191
"""Return all the tags currently displayed in Bear’s sidebar."""
193-
app_ctx = ctx.request_context.lifespan_context
192+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
194193
future = Future[QueryParams]()
195194
await app_ctx.tags_results.put(future)
196195

@@ -208,11 +207,11 @@ async def tags(
208207

209208
@mcp.tool()
210209
async def open_tag(
211-
ctx: Context[ServerSessionT, AppContext],
210+
ctx: Context,
212211
name: str = Field(description="tag name or a list of tags divided by comma"),
213212
) -> list[str]:
214213
"""Show all the notes which have a selected tag in bear."""
215-
app_ctx = ctx.request_context.lifespan_context
214+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
216215
future = Future[QueryParams]()
217216
await app_ctx.open_tag_results.put(future)
218217

@@ -231,11 +230,11 @@ async def open_tag(
231230

232231
@mcp.tool()
233232
async def todo(
234-
ctx: Context[ServerSessionT, AppContext],
233+
ctx: Context,
235234
search: str | None = Field(description="string to search", default=None),
236235
) -> list[str]:
237236
"""Select the Todo sidebar item."""
238-
app_ctx = ctx.request_context.lifespan_context
237+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
239238
future = Future[QueryParams]()
240239
await app_ctx.todo_results.put(future)
241240

@@ -256,11 +255,11 @@ async def todo(
256255

257256
@mcp.tool()
258257
async def today(
259-
ctx: Context[ServerSessionT, AppContext],
258+
ctx: Context,
260259
search: str | None = Field(description="string to search", default=None),
261260
) -> list[str]:
262261
"""Select the Today sidebar item."""
263-
app_ctx = ctx.request_context.lifespan_context
262+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
264263
future = Future[QueryParams]()
265264
await app_ctx.today_results.put(future)
266265

@@ -281,12 +280,12 @@ async def today(
281280

282281
@mcp.tool()
283282
async def search(
284-
ctx: Context[ServerSessionT, AppContext],
283+
ctx: Context,
285284
term: str | None = Field(description="string to search", default=None),
286285
tag: str | None = Field(description="tag to search into", default=None),
287286
) -> list[str]:
288287
"""Show search results in Bear for all notes or for a specific tag."""
289-
app_ctx = ctx.request_context.lifespan_context
288+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
290289
future = Future[QueryParams]()
291290
await app_ctx.search_results.put(future)
292291

@@ -309,15 +308,15 @@ async def search(
309308

310309
@mcp.tool()
311310
async def grab_url(
312-
ctx: Context[ServerSessionT, AppContext],
311+
ctx: Context,
313312
url: str = Field(description="url to grab"),
314313
tags: list[str] | None = Field(
315314
description="list of tags. If tags are specified in the Bear’s web content preferences, this parameter is ignored.",
316315
default=None,
317316
),
318317
) -> str:
319318
"""Create a new note with the content of a web page and return its unique identifier."""
320-
app_ctx = ctx.request_context.lifespan_context
319+
app_ctx: AppContext = ctx.request_context.lifespan_context # type: ignore
321320
future = Future[QueryParams]()
322321
await app_ctx.grab_url_results.put(future)
323322

0 commit comments

Comments
 (0)